Error when adding SharePoint Powershell snapin - powershell

When I run Add-PSSnapin microsoft.sharepoint.powershell I get
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 3.
At line:1 char:1
+ Add-PSSnapin microsoft.sharepoint.powershell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (microsoft.sharepoint.powershell:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
I know this sounds dumb but I have searched Google for about 12 hours trying to just add this snapin. Im writting my first shell script and just need help getting off the start

What is your SharePoint version, 2010 or 2013?
What is your Powershell version? ($PSVersionTable.PSVersion)
SharePoint 2010 expects PowerShell version 2, which you can get to by running powershell -version 2
NB.
(To the commenter above)
If you dont have SharePoint installed on the PC you get this message.
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.SharePoint.PowerShell' is not installed on this machine.
At line:1 char:13
+ Add-PSSnapin <<<< Microsoft.SharePoint.PowerShell
+ CategoryInfo : InvalidArgument: (Microsoft.SharePoint.PowerShell:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

From your question I can understand you are using powershell version 3.0.
Please reboot your system and then try to add the snap-in.. It should work for you.

Related

powershell Microsoft.PowerShell.Utility module could not be loaded

I have this problem in a brand new workstation with Windows 10 installed: on powershell, the 5.1, when I call "Write-Host 'test'" I receive
Write-Host : The 'Write-Host' command was found in the module
'Microsoft.PowerShell.Utility', but the module could not
be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Utility'.
At line:1 char:1
+ Write-Host "test"
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Write-Host:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
And if I try to Import-Module I receive an error.
I installed the powershell 7.2 and in that case I have no problem, but I must use the 5.1 for compatibility reasons.
I already tried to remove/reinstall the powershell windows feature but no way.
Does anyone have a suggestion?
Thx

Set-PnPSite -LogoFilePath throws error? Which version of SharePointPnPPowerShellOnline required? Mine is 3.20.2004.0

Which version of SharePointPnPPowerShellOnline does support below command? Mine is 3.20.2004.0 and trying to update Modern teamsite in sharepoint online environment.
Set-PnPSite -LogoFilePath c:\images\mylogo.png
Set-Variable : A parameter cannot be found that matches parameter name 'LogoFilePath'.
At line:1 char:13
+ set pnpsite -LogoFilePath C:\Project\Images\FPASiteLogo.png
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Variable], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetVariableCommand
Tested the same version PnP PowerShell which is the latest version and LogoFilePath parameter is available, please see the PowerShell snippet:
But the site needs to be a Moder Site:
Reference:
Set-PnPSite

Get-ComputerInfo fails on Windows 7

Should this work?
>$PSVersionTable.PSVersion.ToString()
5.1.14409.1018
>(Get-CimInstance -ClassName CIM_OperatingSystem).Caption
Microsoft Windows 7 Enterprise
>Get-ComputerInfo
Get-ComputerInfo : Unable to find an entry point named 'GetFirmwareType' in DLL 'kernel32.dll'.
At line:1 char:1
+ Get-ComputerInfo
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-ComputerInfo], EntryPointNotFoundException
+ FullyQualifiedErrorId : System.EntryPointNotFoundException,Microsoft.PowerShell.Commands.GetComputerInfoCommand
Appears to be an issue with PowerShell 5.1 that wasn't corrected until PowerShell 6. I found this bug report on the PowerShell GitHub site. Bugs for PowerShell 6 are typically not backported to PowerShell 5.x.
There are several commands added in PS 5.1 that don't work at all on Windows 7. Resolve-DnsName, for example.

Add-PSSnapin Microsoft.Crm.PowerShell not installed error

Trying to script an upgrade for my Dynamics organization following this TechNet blog.
But running into the below error which I understand, but not sure the process to get the PSSnapin onto my system.
PS C:\Program Files\Dynamics SDK\SDK\Bin> Add-PSSnapin Microsoft.Crm.PowerShell
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.Crm.PowerShell' is not installed on this computer.
At line:1 char:1
+ Add-PSSnapin Microsoft.Crm.PowerShell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Crm.PowerShell:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
First of all, sign in with the Administrator account on your Microsoft Dynamics 365 server.
Then in elevated mode Run
Add-PSSnapin Microsoft.Crm.PowerShell
If you have no registered then use the Use PowerShell cmdlets for XRM tooling to connect to Dynamics 365
You can externally also download the same from GITHUB:
Link provided by theMadTechnician
Hope it helps

Unable to Use Windows Update COM object in RemotePS sessions

Im trying to change the windows update settings in a remote server using powershell, but when i run the below commands it gives me an error.
PS C:\Windows\system32> Enter-PSSession opalisbinary
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings = (New-Object -com "Microsoft.Update.AutoUpdate").Settings
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.NotificationLevel=2
Property 'NotificationLevel' cannot be found on this object; make sure it exists and is settable.
At line:1 char:14
+ $AUSettings. <<<< NotificationLevel=2
+ CategoryInfo : InvalidOperation: (NotificationLevel:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.IncludeRecommendedUpdates=$true
Property 'IncludeRecommendedUpdates' cannot be found on this object; make sure it exists and is settable.
At line:1 char:14
+ $AUSettings. <<<< IncludeRecommendedUpdates=$true
+ CategoryInfo : InvalidOperation: (IncludeRecommendedUpdates:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
[opalisbinary]: PS C:\Users\superv\Documents> $AUSettings.Save()
You cannot call a method on a null-valued expression.
At line:1 char:18
+ $AUSettings.Save <<<< ()
+ CategoryInfo : InvalidOperation: (Save:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Although when i run it locally on the server it works fine...
Could anyone please help me.
Does it work when you connect via Remote desktop and run the commands? It also depends on the bittnes. I don't know the Microsoft.Update.AutoUpdate, so I'm just guessing, but - is it available for x64 version of PowerShell? In other words if you run it locally in x64 version and x86, do you see the errors?
I am sorry, I could not find a real answer. What I found is this link which states that remote PS sessions can be used with SCCM 2012, but they could not with SCCM 2007.
This does not help you, but it seems that not all COM objects are compatible with remote PS sessions.