Dear staf-users,
I am having problems running a Powershell script, test.ps1, with the "STAF
PROCESS START SHELL" command.
The script loads a Powershell snapin, Storage.Management.Powershell.Admin,
and executes a command, get-subsystem, implemented by the snap-in.
This is the content of the powershell script, test.ps1.
C:\>type test.ps1
add-pssnapin Storage.Management.Powershell.Admin
get-subsystem
C:\>
C:\>
This is the expected result for running the script in the DOS command
prompt:
C:\>powershell.exe -ExecutionPolicy UNRESTRICTED -command c:\test.ps1
There is no subsystems added.
However, if the powershell script is run with "STAF PROCESS START SHELL"
command, I ran into problems registering the snapin, as seen from the error
messages below:
C:\>STAF local PROCESS START SHELL "powershell.exe -ExecutionPolicy
UNRESTRICTED -command %c" COMMAND c:\test.ps1 WAIT RETURNSTDOUT
RETURNSTDERR SAMECONSOLE
Response
--------
{
Return Code: 0
Key : <None>
Files : [
{
Return Code: 0
Data :
}
{
Return Code: 0
Data : Add-PSSnapin : No snap-ins have been registered for
Windows PowerShell version 2.
At C:\test.ps1:3 char:13
+ add-pssnapin <<<< Storage.Management.Powershell.Admin
+ CategoryInfo : InvalidArgument:
(Storage...owershell.Admin:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId :
AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
The term 'get-subsystem' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the pa
th is correct and try again.
At C:\test.ps1:4 char:14
+ get-subsystem <<<<
+ CategoryInfo : ObjectNotFound: (get-subsystem:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
}
]
}
C:\>
I will appreciate your help to resolve this problem. Thanks.
Regards,
John Andoh
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users