Datastage list jobs - datastage

I am trying to execute a command from datastage job for list listing all the jobs in a project which are in aborted/crashed/stopped status. The command I am using is given below.
/opt/IBM/InfoSphere/Server/DSEngine/bin/dsjob -domain XXXXX:9445 -user XXXX-password XXXXX-server XXXXX -ljobs -status 3/96/97 DEV.
But its giving me the below error
Command Syntax:
dsjob [-authfile <authfile> | -file <file> <domain> <DataStage server> | [-domain <domain> | -url <url>] -user <user> -password <password> -server <DataStage server>] | -domain <domain> [-user <user>] -server <DataStage server>
<primary command> [<arguments>]
Valid primary command options are:
-run
-stop
-lqueues
-lprojects
-ljobs
-linvocations
-lstages
-llinks
-projectinfo
-jobinfo
-stageinfo
-linkinfo
-lparams
-paraminfo
-log
-logsum
-logdetail
-lognewest
-report
-jobid
-import
Status code = -9999 DSJE_DSJOB_ERROR.
Any idea on this

Add the -server option - this option is missing in my eyes.
-server <enginename>
Dokumentation can be found here

A bit late, but it could help someone else.
Michael already told you to add the "-server" option (don't forget the space).
Now if you only want aborted and warning job, add the "status" option with the status code you want:
dsjob -ljobs -status 3/96/97 my_DS_project
List of status code (from the IBM doc):
1 "Finished"
2 "Finished (see log)"
11 "Validated OK"
12 "Validated (see log)"
21 "Has been reset"
99 "Compiled"
NOT Runnable Job Status (reset job)
0 "Running"
3 "Aborted"
13 "Failed validation"
96 "Crashed"
97 "Stopped"
98 "Not Compiled"
Valentin

try excluding the logon details (server/user/password), it will try using the current user name on same server

Related

Get Mac-Address-Table from HPE Aruba Swtich with plink ssh

this is my code:
#(
' ', #for "Press any key to continue"
'show mac-address'
) | plink <ip> -P 22 -ssh -v -l admin -pw pwd -batch
Read-Host -Prompt “Press Enter to exit”
sometimes i get this output:
←[1;13r←[1;1HSession sent command exit status 0
Main session channel closed
All channels closed
and sometimes i get this output:
Remote side unexpectedly closed network connection
FATAL ERROR: Remote side unexpectedly closed network connection
If i write the plink command without Pipe:
plink <ip> -P 22 -ssh -v -l admin -pw pwd -batch
It works. But i need it automated
I happen to have an Aruba switch and found that specifying non-interactive SSH with -batch, or commands with -m, just causes the switch to disconnect your session like you're seeing. Maybe there's a setting to allow it?
I found this works pretty well, using more of a .net approach due to issues with Start-Process redirection. This opens plink in a separate process, and sends commands to its stdin:
# set up a process with redirection enabled
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = "plink.exe" #process file
$psi.UseShellExecute = $false #start the process from it's own executable file
$psi.WorkingDirectory = 'C:\Program Files (x86)\PuTTY' # or add to path
$psi.RedirectStandardInput = $true #enable the process to read from our standard input
$psi.RedirectStandardOutput = $true #enable reading standard output from powershell
# update these:
$psi.Arguments = "$IPADDRESS -P 22 -ssh -l admin -pw $PASS"
# launch plink
$plink = [System.Diagnostics.Process]::Start($psi);
sleep 1
# send key presses to plink shell
$plink.StandardInput.AutoFlush = $true
$plink.StandardInput.WriteLine() # press return to begin session
$plink.StandardInput.WriteLine() # press any key to continue (banner)
$plink.StandardInput.WriteLine('show mac-address') # get macs
$plink.StandardInput.WriteLine('exit') # exit and confirm logoff
$plink.StandardInput.WriteLine('exit')
$plink.StandardInput.WriteLine('y')
# read output from process
$output = $plink.StandardOutput.ReadToEnd()
# exit plink
$plink.Close()
# outputs like so (trimmed of banners etc)
$output
MAC Address Port VLAN
----------------- ------------------------------- ----
005056-00000X 15 1
005056-00000Y 9 1
005056-00000Z 11 1
You may have to play around with the commands a bit, but I found plink was pretty generous with how quickly input gets thrown at it
I did notice if the plink process is waiting (ssh session still connected), then ReadToEnd() will wait forever. Maybe it can be replaced with a ReadLine() loop, but it can be hard to tell when it's done.
As mentioned in your comment (and edited in your question)
plink <ip> -P 22 -ssh -v -l admin -pw pwd -batch `n;show mac-address
works fine. You could automate this by just joining your statements together with Join-String:
$ip = "192.168.123.123"
#(
"\n",
"show-mac-address",
"just-another-command"
) | Join-String -Separator ";" | ForEach-Object {
plink $ip -P 22 -ssh -v -l admin -pw pwd -batch $_
}
This basic example simply renders to plink 192.168.123.123 -P 22 -ssh -v -l admin -pw pwd -batch \n;show-mac-address;just-another-command.
This happens in two steps: Join-String takes your input array from the pipeline and joins it together to one string: \n;show-mac-address;just-another-command. This one string is then passed thru the pipeline to ForEach-Object. This cmdlet takes it, sets PsItem to this Value and executes the plink command one time for every string passed to it (which is in fact only one element)
For older PowerShell-Versions [string]::Join(";", $statements) might be of help for you.

Having issue with Microsoft Teams access policy - New-CsApplicationAccessPolicy

The use case i am working is create online meeting and i followed the following documentation https://learn.microsoft.com/en-us/graph/api/application-post-onlinemeetings?view=graph-rest-1.0&tabs=http
As part of this, Admin needs to create application access policy and grant it to a user.https://learn.microsoft.com/en-us/graph/cloud-communication-online-meeting-application-access-policy
While executing New-CsApplicationAccessPolicy cmdlet I am having the following error.
e.g New-CsApplicationAccessPolicy -Identity Test-policy -AppIds "ddb80e06-92f3-4978-bc22-a0eee85e6a9e", -Description "description here"
ERROR
Get-CsOnlineSession: /Users/avnika/.local/share/powershell/Modules/MicrosoftTeams/2.3.1/netcoreapp3.1/SfBORemotePowershellModule.psm1:63
Line |
63 | $remoteSession = & (Get-CsOnlineSessionCommand)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The remote server returned an error: (404) Not Found.
Invoke-Command: /Users/avnika/.local/share/powershell/Modules/MicrosoftTeams/2.3.1/netcoreapp3.1/SfBORemotePowershellModule.psm1:22959
Line |
22959 | … -Session (Get-PSImplicitRemotingSession -CommandName ‘New-CsApplic …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot validate argument on parameter ‘Session’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
2:20
this error when i execute below policy New-CsApplicationAccessPolicy -Identity Millo-Video-policy -AppIds “334941f7-50e4-4b19-9d5d-22328ad41553” -Description “video delegation policy for app”
I would appreciate if you can help me how to solve this problem.
P.s. I am using personal azure account
This cmdlet runs using skype connecter. But now this cmdlet is added in latest powershell module. please upgrate powershell module and run the cmdlet. please go through this link
I tried the following steps and its working:
Upgrade the microsoft teams powershell module to the latest (also follow the above steps provided by Kartheek above)
Connect-MicrosoftTeams #Enter global Administrator account credential and make sure that you see Admin account details in connection output.
Now execute the New-CsApplicationAccessPolicy
Make sure the powershell connects/works.
Usually i test the above steps in test demo tenant, before doing it in prod. Test the same and confirm if you can still repro the issue.

Service cannot be started due to the following error: Cannot open service on computer '.'

I'm trying to Start a service using Powershell and using the code below
function CheckServiceStatus {
param($winupdate)
$getservice = Get-Service -Name $winupdate
if($getservice.Status -ne $running){
stop-service $winupdate
Start-Service $winupdate
Write-output "Starting" $winupdate "service"|out-file "C:\Users\Mani\Desktop\abc.txt"
Add-Content C:\Users\Mani\Desktop\abc.txt $getservice.Status
}
}
Read-Host -Prompt "Press Enter to exit"
#Variables
$winupdate = 'vsoagent.192.Shalem'
$running = 'Running'
CheckServiceStatus $winupdate
I got the following error:
Service 'ABC' cannot be stopped due to the following error: Cannot
open ABC service on computer '.'
I found some link here on our forum but couldn't resolve. Please suggest
If you want to start/stop/etc services, you need elevated privileges (run as Admin). You can still get information about the service, but that's it. If you want to include a more verbose error, include this:
$isadmin = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
if($isadmin){
Write-Error "You need elevated privileges to run this script"
exit(1)
}
...
Rest of your code
Or even better, if you're running Powershell 4.0 or higher (You can get it by checking $PSVersionTable), you can include
#Requires -RunAsAdministrator
At the top of your file, and you won't be able to run it without admin privilages.
I had this issue while running the command on PowerShell ISE. All I did was start the PowerShell ISE as an administrator.
Look into Event Viewer and find more details. In my case, I have found relevant info in Administrative Events, then Service Control Manager. The error was related to insufficient privileges given for the account. The service was creating a new file and this task failed. Of course, your error's details are probabably different, but that is the tip.

Creating a log for a powershell command

I have a simple command to create a CSV file in powershell. Is there a way to log this information separate from the file? I will be needing to manipulate the CSV file, so I don't want to rely on it being my only way of logging the data.
You can also export the output of commands by using the > and >> operators.
example:
You can write all of the Adobe services and their information to a file with this code:
get-service -DisplayName Adobe* > C:\services.txt
if you wanted to append to that with Windows services:
get-service -DisplayName Windows* >> C:\services.txt
so if you wanted to export your CSV to a file you can easily do so by adding a > at the end of the command pointing to the filename you wish to export it to:
> C:\Log_$date.csv
and if you ever needed to append more logs you can simply do so by using the >>
>> C:\Log_$date.csv
if you use > it will overwrite and existing data in the file with new data. >> appends.
If you need a log for people who are in charge of the production you can add your own application log using dedicated Cmdlets. A the moment I create and use one PowerShell log for all my scripts to publish details of the execution (information) and errors (in coordination with good exception handling) for people who are in charge of the production. You can dedicate a log for one script (as it exists a log for DNS etc.)
Here is an example :
# List of logs
Get-EventLog -list
# Creating your own log
New-EventLog -LogName "SlxScripting" -Source "MaSource"
# List of logs
Get-EventLog -list
# Writting in your own log
Write-EventLog -LogName "SlxScripting" -EventId 12 `
-Message "Mon Message"
-Source "MaSource" -EntryType Warning
# Reading in your own log
Get-EventLog -LogName "SlxScripting"
# Suppressing your log
Remove-EventLog -LogName "SlxScripting"

Powershell 2: Unable to suppress warning message

I am making a cmdlet call to 'set-distributiongroup' in powershell 2. I am simply setting the value of the parameter 'hiddenFromAddressListsEnabled' to a pre-defined boolean value.
However, no matter what I try, it displays a warning message if the boolean assignment is not actually changing the current value of 'hiddenFromAddressListsEnabled'.
Here is the main command I'm invoking:
set-DistributionGroup -identity TestGroup `
-hiddenFromAddressListsEnabled=$true
Let's semantically define what I have above as 'command'.
Now, I've tried adding several different variants, all with proper line-continuation and syntax. Here are those variants:
command > $null
command 2> $null
command -ErrorAction:silentlycontinue
command -ErrorVariable $throwAway
command -WarningAction:silentlycontinue
command -WarningVariable $throwAway
$var = command
Regardless of various combinations of one or more of the above, I still get a yellow WARNING: message spit to output. Specifically, this:
WARNING: The command completed successfully but no settings of
'<xxxxxx>/Users/TestGroup' have been modified.
Any suggestions on a key concept I'm not understanding? I want the command to not produce this output, and I want it to silently continue if this occurs.
Thanks!!
I've been trying to suppress the warning messages when stopping a service:
WARNING: Waiting for service 'Service Description' to finish stopping...
The following worked for me:
Stop-Service $svc.Name -WarningAction SilentlyContinue
If it's just a warning that cause problem why don't you set in your script $WarningPreference variable ?
PS C:\> $WarningPreference='silentlycontinue'
PS C:\> Write-Warning "coucou"
PS C:\> $WarningPreference='continue'
PS C:\> Write-Warning "coucou"
AVERTISSEMENT : coucou
just bumped this topic when searching on the issue,
my case PowerShell v2 , only after setting
$WarningPreference = "SilentlyContinue"
Write-Warning "blah" - returned me nothing... the parameter on the command didn't changed much too on my end.
You may be hitting this bug: http://connect.microsoft.com/PowerShell/feedback/details/541500/warning-verbose-and-debug-streams-do-not-respect-action-preferences-the-way-they-should
Anyway, your command should look like:
Set-DistributionGroup -Identity TestGroup -HiddenFromAddressListsEnabled $true
Your command is wrong. Which is the the reason why you get a yellow error message. The command should look like:
Set-DistributionGroup -Identity TestGroup -HiddenFromAddressListsEnabled $true
Or
Set-Distributionaliste -Identity TestGroup -HiddenFromAddressListsEnabled:$true
But not
Set-DistributionGroup -Identity TestGroup -HiddenFromAddressListsEnabled=$true
I was getting the same problem with the Exchange Management Console in 2010. Problem is the EMC runs on PowerShell 2.0, which as stated before has some bugs around warning preferences.
I found a cheeky workaround was to run my script in a vanilla PowerShell 4.0 shell, and then import the EMC cmdlets and start a new remote PS session like so...
. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'
Connect-ExchangeServer -auto
...then, -WarningAction:SilentlyContinue suddenly starts behaving itself.
You should try
Set-DistributionGroup -Identity TestGroup -HiddenFromAddressListsEnabled $true -WarningAction silentlyContinue
I bumped into same issue, the following command seems to do the job (PS 3.0) :
Stop-Service<or whatever command> $svc.Name -WarningPreference SilentlyContinue
Don't know exactly what difference it makes with -WarningAction, though.
Hope this helps !
If you invoke powershell versión 2.0, you should use "-WarningAction silentlyContinue". I was having the same issue, but in the script, if I invoke, for example "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -versión 2.0" , then you can use this parameter. I was trying on a scheduled task and using a ps1 script.
Try something like that:
PS C:\> {command} | Out-Null
For more Information: Technet: Out-Null