PowerShell : Cannot find a provider with the name - powershell

Trying to update existing powershell version(V2) to latest version (V5.) on about 50 remote computers.
Obtained install instructions and script(Install-WMF5.1) from https://msdn.microsoft.com/en-us/powershell/wmf/5.1/install-configure
and script executes successfully on local machine.
Environment is as follows
- Win 7, Sp1
- PSRemoting Enabled
- Powershell is run as admin
When running the below command, I get the following error message. "Cannot find a provider with the name '"
Invoke-Command -FilePath \Install-WMF5.1.ps1 -ComputerName comp1
Please assist.
Thank you in advance

I had this same issue when installing WMF 5.1 to a Server 2008 R2 box. Installing .NET Framework 4.5.2 resolved the issue for me.

Related

New-ExoPSSession: Index was out of range

Im developing a script that connects to Exchange Online Microsoft 365, but when the script executes the cmdlet "Connect-ExchangeOnline", it ends with errors.
The specific instruction is:
Connect-ExchangeOnline -Organization $myTenant -AppId $AppId -Certificate $myCert
The variables in the parameters are correct, the error says:
New-ExoPSSession: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
I can load the module succesfully. The script connects to Exchange Online trough a cert installed in my machine, my script can read it without issues.
I'm running this script in Powershell V4 and .Net Framework 4.7.1. If i execute the same script in another machine with PowerShell V5.1 I can connect to Microsoft 365 Exchange Online succesfully. I tried with a lower version (ExchangeOnlineManagement 1.0.1) but this version hasn't got those parameters (Organization, AppId, etc...), I'm now using 2.0.3 version. I not sure if you can upgrade Powershell to 5.1.
Does anyone know why i can't connect to Exchange Online?
I've been struggling with this issue, and I finally found a solution.
Turns out running Import-Module ExchangeOnlineManagement before Connect-ExchangeOnline causes this error.
Removing Import-Module ExchangeOnlineManagement was enough to allow Connect-ExchangeOnline to connect without the New-ExoPSSession: Index was out of range error
EXO V2 is only supported on PowerShell 5.1 and later. If you want to use PowerShell 4.0 you will have to use EXO V1.
I'm not familiar enough with the EXO module to how or whether you can use EXO V1 in your current environment. If V2 is required for modern Exchange Online management then you will need to upgrade your nodes to use WMF 5.1 or install PowerShell Core (7+) and use EXO V2 from there.
PowerShell Core installs in parallel to Windows PowerShell so there is less of a risk of impacting other code which requires PowerShell 4.0 if you go this route.
I am using Windows PowerShell 5.1 and this seems to be an issue that's introduced in ExchangeOnlineManagement version 2.0.4.
Downgrading to 2.0.3 worked for me.
PowerShell needs to be started in elevated mode. However, my error was caused by RunAs with a domain admin account. Using RunAs with a local admin account works. YMMV.

Royal TS PowerShell remote session does not work

I need to set up a PowerShell entry which connects with the PowerShell of the given server.
I haven't found anything helpful except of this instruction.
Instead of getting a PowerShell connection with the desired server I get a PowerShell connection of my local PC.
I also tried the same for cmd.exe and for Git Bash with no success.
I also tried to create tasks, but also with no success.
In all the cases I get the connection with my local PC.
My host system is: Windows 8.1 Enterprise 64 Bit
Royal TS: 3.2.9 (Build #60630)
What am I doing wrong?
Mostly solved :-)
By External Application Settings for PowerShell:
Command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments: -NoExit Enter-PSSession -computername my-remote-server
Working Directory: C:\Windows
-computername my-remote-server was missing, thatwhy it has not worked.
Unfortunatelly Working Directory does not work, I still land in C:\Users\j.sinitson\Documents.
Does someone know how to solve that?

Importing modules in a remote session

We have one script server running Windows Server 2012 with PowerShell 4.0 and multiple other servers that run Windows Server 2008R2 with PowerShell 4.0.
What we're trying to do is use the function Get-FSRMQuota from the module FileServerResourceManager found on Server 2012 on the 2008R2 file servers. When in an RDP session on the 2008R2 file server, this can be easily done:
# From PowerShell on the file server:
New-PsSession $ScriptSever
Invoke-Command -Computer $ScriptSever {Import-Module FileServerResourceManager}
Invoke-Command -Computer $ScriptSever {Get-FSRMQuota}
However, all our scripts launch from the script server and are managed there. So we have a job that's initiated on the script server (2012) to run on the 2008R2 servers using PS Remoting. But from within this job it's not possible to import a module from the script server that initiated the job.
So my question, is there a way to import the module FileServerResourceManager from the script server into the remote session on the file server?
I hope I made it clear, as it's a bit difficult to explain. Thank you for your help.
It's not possible. According to https://technet.microsoft.com/en-us/library/jj900651(v=wps.620).aspx, FileServerResourceManager is only available as of Windows 2012.

Jenkins - Execute 64bit Powershell commands

I'm trying to execute a Powershell script which contains Sharepoint commands as part of my Jenkins job.
Seemingly, the Sharepoint snapin is only available to 64bit Powershell sessions. A 32bit session does not show the Sharepoint snapin.
64bit
PS C:\Users\user> Get-PSSnapin -Registered
Name : Microsoft.SharePoint.PowerShell
PSVersion : 1.0
Description : Register all administration Cmdlets for Microsoft SharePoint Server
Most suggestions to run a 64bit Powershell are to run from the following path. Even if I test this from a 32bit command prompt, I still get a 32bit Powershell instance
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
How can I execute 64bit (and therefore Sharepoint) Powershell commands via Jenkins?
Installing the 64bit JRE and starting Jenkins with that (edit jenkins.xml) resolved the issue.

'Set-AdfsGlobalWebContent' is not recognized as the name of a cmdlet

I am trying to change company name using 'Set-AdfsGlobalWebContent' of powershell 4.0 .
I am using power-shell ISE but I am not able to get this command.
I am working on windows server 2012 R2
Anybody explain me Why that command is not showing in intelligence? is I am missing something?
after executing this command forcefully it gives "'Set-AdfsGlobalWebContent' is not recognized as the name of a cmdlet" error.
Thanks in Advance !!!
From technet:
To use these cmdlets you must have previously installed the AD FS server role. This can be done using the Add Roles and Features Wizard in Server Manager or optionally, you can use the Install-WindowsFeature AD-Federation-Services cmdlet at a Windows PowerShell prompt to add the role.