We are switching from cmd.exe to PowerShell. How does one get the auto-edit variables from a CM job into the PowerShell script?
An example would be great!!
-- Goo
Getting Auto-Edit variables into PowerShell
PowerShell Script for working with Control-M Jobs
Hi,
The changes you will need to make in your Control-M jobs would be:
General Tab:
Filename: powershell.exe
Filepath: c:/windows/system32/WindowsPowerShell/v1.0/
(check powershell version and set directory accordingly)
SET Tab
1st Parameter: -command
2nd Paramter: "<location_of_script_on_box>" (eg. d:\controlm\scripts\test.ps1)
3rd Paramter: "Brahmos"
4th Paramter: "admin"
5th Paramter: "123321xxx123321"
and so on...
For eg. my purpose is to read the server name, id and password from Control-M Job.
Then 3rd Param is my server name: Brahmos
4th Param is my ID: admin
and 5th param is my password: 123321xxx123321
Now sample script for you:
##################Sample Script###################
param ([string] $serverName ,[string] $userID, [string] $Password )
if($serverName -eq "" -or $userID -eq "" -or $Password -eq "")
{
Write-Host ("parameters populated incorrectly......")
exit(1)
break;
}
else
{
Write-Host "Server name passed is: " $serverName
Write-Host "User ID passed is: " $userID
Write-Host "Password passed is: " $Password
}
##############Sample Script Ends###################
If all parameters are not passed job would fail and if all parameters are there it would print their values.
I hope it helps
The changes you will need to make in your Control-M jobs would be:
General Tab:
Filename: powershell.exe
Filepath: c:/windows/system32/WindowsPowerShell/v1.0/
(check powershell version and set directory accordingly)
SET Tab
1st Parameter: -command
2nd Paramter: "<location_of_script_on_box>" (eg. d:\controlm\scripts\test.ps1)
3rd Paramter: "Brahmos"
4th Paramter: "admin"
5th Paramter: "123321xxx123321"
and so on...
For eg. my purpose is to read the server name, id and password from Control-M Job.
Then 3rd Param is my server name: Brahmos
4th Param is my ID: admin
and 5th param is my password: 123321xxx123321
Now sample script for you:
##################Sample Script###################
param ([string] $serverName ,[string] $userID, [string] $Password )
if($serverName -eq "" -or $userID -eq "" -or $Password -eq "")
{
Write-Host ("parameters populated incorrectly......")
exit(1)
break;
}
else
{
Write-Host "Server name passed is: " $serverName
Write-Host "User ID passed is: " $userID
Write-Host "Password passed is: " $Password
}
##############Sample Script Ends###################
If all parameters are not passed job would fail and if all parameters are there it would print their values.
I hope it helps
Last edited by piyush on 10 Mar 2013 1:20, edited 1 time in total.
No Go...... Here is what I tried.
param ([string] $serverName ,[string] $userID, [string] $Password )
$exe = "F:\Program Files\BMC Software\CONTROL-M Server\Ctm_server\Exe\ctmvar.exe"
if($serverName -eq "" -or $userID -eq "" -or $Password -eq "")
{
$body = "parameters populated incorrectly......"
&$exe -action set -var "%%\EMAIL_BODY" -varexpr $body
exit 0
}
else
{
$body = "Server name passed is: " + $serverName +
"User ID passed is: " + $userID +
"Password passed is: " + $Password
&$exe -action set -var "%%\EMAIL_BODY" -varexpr $body
exit 0
}
I get an email saying "parameters populated incorrectly".
Auto-Edit Variables are set as
PARM1 AAAAAAAAAAAAAAAA
PARM2 BBBBBBBBBBBBBBBB
PARM3 CCCCCCCCCCCCCC
Any ideas????
--Goo
param ([string] $serverName ,[string] $userID, [string] $Password )
$exe = "F:\Program Files\BMC Software\CONTROL-M Server\Ctm_server\Exe\ctmvar.exe"
if($serverName -eq "" -or $userID -eq "" -or $Password -eq "")
{
$body = "parameters populated incorrectly......"
&$exe -action set -var "%%\EMAIL_BODY" -varexpr $body
exit 0
}
else
{
$body = "Server name passed is: " + $serverName +
"User ID passed is: " + $userID +
"Password passed is: " + $Password
&$exe -action set -var "%%\EMAIL_BODY" -varexpr $body
exit 0
}
I get an email saying "parameters populated incorrectly".
Auto-Edit Variables are set as
PARM1 AAAAAAAAAAAAAAAA
PARM2 BBBBBBBBBBBBBBBB
PARM3 CCCCCCCCCCCCCC
Any ideas????
--Goo
- zailaiboke
- Nouveau
- Posts: 3
- Joined: 01 Aug 2013 12:00
The first two parameters should be:
________________________________________________
FIFA Ultimate Coins
________________________________________________
FIFA Ultimate Coins