Commands not recognized in PSSession
-
Friday, January 25, 2013 11:52 PM
I am working on Windows Server 2012. I have a variety of scripts for configuring different options. This script is not working correctly for me. I execute the script from a workstation that does not have MPIO installed on it.
$srvr = Read-Host "Enter computer name of server on which to install MPIO" Write-Host "" Write-Host "Installing the MPIO feature" Install-WindowsFeature -Name Multipath-IO -ComputerName $srvr -IncludeManagementTools Enter-PSSession -ComputerName $srvr Write-Host "Add new vendor and product IDs for MPIO" Enable-MsdsmAutomaticClaim -BusType iSCSI New-MSDSMSupportedHw -Vendor "EMC" -ProductId "Celerra" Write-Host "List of configured vendor and product IDs" Get-MSDSMSupportedHw Exit-PSSession
The installation of MPIO works just fine. But the MSDSM cmdlets attempting to run within a PSSession are not working on the machine. Here is the output.
PS Z:\scripts> .\Add-UcsHyperVFeatures.ps1
Enter computer name of server on which to install MPIO: vmhost03 Installing the MPIO feature Success Restart Needed Exit Code Feature Result ------- -------------- --------- -------------- True No Success {Multipath I/O} Add new vendor and product IDs for MPIO Enable-MsdsmAutomaticClaim : The term 'Enable-MsdsmAutomaticClaim' 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 path is correct and try again. At Z:\scripts\Add-UcsHyperVFeatures.ps1:15 char:10 + $trash = Enable-MsdsmAutomaticClaim -BusType iSCSI + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Enable-MsdsmAutomaticClaim:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException New-MSDSMSupportedHw : The term 'New-MSDSMSupportedHw' 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 path is correct and try again. At Z:\scripts\Add-UcsHyperVFeatures.ps1:16 char:10 + $trash = New-MSDSMSupportedHw -Vendor "EMC" -ProductId "Celerra" + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (New-MSDSMSupportedHw:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException List of configured vendor and product IDs Get-MSDSMSupportedHw : The term 'Get-MSDSMSupportedHw' 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 path is correct and try again. At Z:\scripts\Add-UcsHyperVFeatures.ps1:18 char:1 + Get-MSDSMSupportedHw + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-MSDSMSupportedHw:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
However, if I copy the contents of the script and paste it into the exact same session from which I ran the script file, the commands work fine. In other words, it appears that the commands are not working within a PSSession if executed from a script file, but they work fine if pasted as a whole within a the same PowerShell window.
Is there something special I should know about using the Enter-PSSession command from within a script file?
.:|:.:|:. tim
All Replies
-
Friday, January 25, 2013 11:57 PMModerator
Enter-PSSession can only be used interactively.
If you want to script executing that on a remote computer, use invoke-command.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
- Proposed As Answer by jrvMicrosoft Community Contributor Saturday, January 26, 2013 1:13 AM
- Marked As Answer by Tim CerlingMicrosoft Community Contributor Saturday, January 26, 2013 3:11 PM
-
Saturday, January 26, 2013 3:16 PMDoh! I guess I forgot what the word 'interactive' meant, seeing that word is in the definition of what this command does. Thanks for the clarification.
.:|:.:|:. tim

