Author Posts

October 4, 2013 at 3:13 am

I have this Windows7(x64) with Powershell 3.0. A remote Windows Server 2012.
Sequence of events.Please suggest why get-volume is failing in the end ?

PS C:\> Get-PSSession

PS C:\> get-module

ModuleType Name ExportedCommands
———- —- —————-
Script ISE {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}
Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}

PS C:\> $s= New-PSSession Win2012

PS C:\> Import-PSSession -Session $s -Module storage

ModuleType Name ExportedCommands
———- —- —————-
Script tmp_vwm2rtre.kr3 {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Add-TargetPortToMaskingSet...}

PS C:\> get-module

ModuleType Name ExportedCommands
———- —- —————-
Script ISE {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}
Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}
Script tmp_vwm2rtre.kr3 {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Add-TargetPortToMaskingSet...}

#Get-volume on its own returns volumes on Win2012 server.

PS C:\> icm lt-800000 {get-volume}
The term 'get-volume' 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.
+ CategoryInfo : ObjectNotFound: (get-volume:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : lt-800000

October 4, 2013 at 3:59 am

When you use Invoke-Command, you're limited to whatever commands are available on the target machine (LT-800000). If that computer isn't running Windows 8 or Server 2012, the Get-Volume cmdlet won't work, regardless of what commands you can run on the client computer.

To support downlevel operating systems, you'll have to get by with the older WMI classes for now. In this case, you could try Get-WmiObject -ComputerName lt-800000 -Class Win32_Volume

October 4, 2013 at 7:19 pm

Thanks I get it now :).

October 5, 2013 at 3:14 am

The module created by the imported session has to be used against the machine from which you imported it, over the session to that machine. You can't then use an imported module in invoke-command