Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, April 20, 2011 6:08 AM
Hi,
I have a command shell script to invoke powershell script. I pass parameters to my command shell script which dont get passed to powershell script. I did add some echo in powershell script to check if the $variable get assigned with the command line paramaters been passed but with no luck.
For example:
from command prompt I execute
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command D:\SCOM_Admin_Scripts\SCOMSetMM.ps1 -computerPrincipalName:scoau182idv0003.globalinfdev.anz.com - numberOfHoursInMaintenanceMode:1 -comment:"Test something"
in my powershell script, I got
param($computerPrincipalName,$numberOfHoursInMaintenanceMode,$comment)
but the values are blank for $computerPrincipalName, $numberOfHoursInMaintenanceMode, $comment
Appreciate any help/support in advance.
Regards
Anil Khiani
All replies (2)
Wednesday, April 20, 2011 6:13 AM âś…Answered
powershell -command "&{D:\SCOM_Admin_Scripts\SCOMSetMM.ps1 -ComputerPrincipalName scoau182idv0003.globalinfdev.anz.com -numberOfHoursInMaintenanceMode 1 -comment "Testsomething"}"
or
powershell -file D:\SCOM_Admin_Scripts\SCOMSetMM.ps1 scoau182idv0003.globalinfdev.anz.com 1 "Test something"
Thursday, April 21, 2011 2:46 AM
thanks. I used args[0]... and assigned to
$principalcomputername = args[0]...
Also, your suggestion for invoking from command prompt helped.
regards
Anil