I am composing a script that will run on a domain controller (windows 2008 R2) checking OU user names but then going out to the users H: drive and checking permissions, both for the root folder and the users folder.
The share permission portion of the script, I would prefer to use Get-SMBShare as opposed to working with WmI. However, my script is running on Windows 2008, so I decided to use implicit remoting to import the modules I need from a Windows 2012 server to run the necessary commands I need.
I used this site as a guide.
Windows PowerShell: Implicit Remoting
Here are my commands (from the desktop of the windows 2008 Server, logged on with domain admin credentials):
$session = New-PSSession -ComputerName w12-r12-01V invoke-command {import-module smbshare} -session $session Export-PSSession -Session $session -CommandName *-SMB* -OutputModule RemSMB -AllowClobber Directory: X:\Users\administrator.XXXX\Documents\WindowsPowerShell\Modules\RemSMB Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 1/14/2017 10:03 PM 99 RemSMB.format.ps1xml -a---- 1/14/2017 10:03 PM 576 RemSMB.psd1 -a---- 1/14/2017 10:03 PM 96492 RemSMB.psm1 Remove-PSSession -Session $session
Then, when I try to import, the invoke method portion fails… I was successfully able to do an implicit remote using the ‘activedirectory’ module as the example, but ‘SMBShare’ module is failing.
Is this possible with SMBSHARE module?
PS C:\Users\administrator.XXXX> Import-Module RemSMB -prefix Rem Cannot invoke method. Method invocation is supported only on core types in this language mode. At C:\Users\administrator.XXXXXXX\Documents\WindowsPowerShell\Modules\RemSMB\RemSMB.psm1:22 char:1 + $script:WriteHost = $executionContext.InvokeCommand.GetCommand('Write ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage Cannot invoke method. Method invocation is supported only on core types in this language mode. At C:\Users\administrator.XXXXXXX\Documents\WindowsPowerShell\Modules\RemSMB\RemSMB.psm1:23 char:1 + $script:WriteWarning = $executionContext.InvokeCommand.GetCommand('Wr ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage Cannot invoke method. Method invocation is supported only on core types in this language mode. At C:\Users\administrator.XXXXXXX\Documents\WindowsPowerShell\Modules\RemSMB\RemSMB.psm1:24 char:1 + $script:WriteInformation = $executionContext.InvokeCommand.GetCommand ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage Cannot invoke method. Method invocation is supported only on core types in this language mode. At C:\Users\administrator.XXXXXXX\Documents\WindowsPowerShell\Modules\RemSMB\RemSMB.psm1:25 char:1 + $script:GetPSSession = $executionContext.InvokeCommand.GetCommand('Ge ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage Cannot invoke method. Method invocation is supported only on core types in this language mode. At C:\Users\administrator.XXXXXXX\Documents\WindowsPowerShell\Modules\RemSMB\RemSMB.psm1:26 char:1 + $script:NewPSSession = $executionContext.InvokeCommand.GetCommand('Ne ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage