Import-PSSession: proxy creation was skipped for command '%' because PowerShell could not verify its name as safe

I have a Sharepoint farm setup and I'm connecting to one of my application / search servers from a Windows 7 computer in a domain using remote PowerShell. There are powershell 2 on the client and application servers with the execution policy enabled, unlimited and allowed. In addition, I run cmdlets as a domain administrator account.

I can create a session on a remote server using the following cmdlets:

$Session = New-PSSession -ConfigurationName "Microsoft.PowerShell" -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication "Kerberos" Import-PSSession $Session -AllowClobber 

However, when I import the session, I get the following entry:

 Import-PSSession : Proxy creation has been skipped for '%' command, because PowerShell couldn't verify its name as safe. At line:1 char:17 + Import-PSSession <<<< $Session -AllowClobber + CategoryInfo : InvalidData: (:) [Import-PSSession], InvalidOperationException + FullyQualifiedErrorId : ErrorSkippedUnsafeCommandName,Microsoft.PowerShell.Commands.ImportPSSessionCommand Import-PSSession : Proxy creation has been skipped for '?' command, because PowerShell couldn't verify its name as safe. At line:1 char:17 + Import-PSSession <<<< $Session -AllowClobber + CategoryInfo : InvalidData: (:) [Import-PSSession], InvalidOperationException + FullyQualifiedErrorId : ErrorSkippedUnsafeCommandName,Microsoft.PowerShell.Commands.ImportPSSessionCommand Import-PSSession : Could not resolve remote alias 'ise'. At line:1 char:17 + Import-PSSession <<<< $Session -AllowClobber + CategoryInfo : OperationTimeout: (:) [Import-PSSession], ArgumentException + FullyQualifiedErrorId : ErrorCouldntResolveAlias,Microsoft.PowerShell.Commands.ImportPSSessionCommand 

Can someone help solve this error?

+7
source share
2 answers

I solved this by simply entering a remote session, rather than importing it. Then I was able to add the SharePoint snap-in installed on the remote computer and run my script.

 $Session = New-PSSession -ConfigurationName "Microsoft.PowerShell" -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication "Kerberos" Enter-PSSession $Session Add-PSSnapin Microsoft.SharePoint.PowerShell <Cmdlets or script goes here> Exit-PSSession Remove-PSSession -ID $Session.ID [GC]::Collect() 

Another option is to use the Invoke-Command cmdlet with the ScriptBlock parameter, for example.

 $Session = New-PSSession -ConfigurationName Microsoft.PowerShell -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication Kerberos Invoke-Command -Session $Session -ScriptBlock { Add-PSSnapin Microsoft.SharePoint.PowerShell } Invoke-Command -Session $Session -ScriptBlock { <Your cmdlet here.> } Remove-PSSession -ID $Session.ID [GC]::Collect() 
+6
source

The error is that you are trying to import the entire set of commands from a remote server. Not quite sure why you allow saliva.

Personally, I just import the appropriate SHarePoint modules, and not the entire remote workspace.

Does import work?

+1
source

All Articles