Hi again
Just a quick post that will show you how you can check if the SharePoint snapin is loaded and if it isn’t, how to add it. This will be a really useful function that you can use at the start of all your SharePoint PowerShell scripts and the solution if you receive an error similar to this:
The term ‘_________’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
pelling of the name, or if a path was included, verify that the path is correct and try again.
This error occurs because the SharePoint Snapin is not loaded and you try using a command like: Get-SPWeb, Get-SPUser, Enable-SPFeature, Backup-SPFarm, etc.
Anyway here is the PowerShell script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | function Check-SPSnapin { Write-Host "Checking for SharePoint Snapin. Please wait....`r`n" if ((get-pssnapin | where-object {$_.name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { # Snapin wasn't loaded so we load it... Write-Host "Loading SharePoint Snapin. Please wait...`r`n" add-pssnapin "Microsoft.SharePoint.PowerShell" # This is just a final check to see if the Snapin is now successfully loaded if ((get-pssnapin | where-object {$_.name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) { # Snapin still can not be detected, log it. You could put "exit" here if you desire. Write-Host "SharePoint Snapin was not successfully added.`r`n" } else { # It is now successfully loaded Write-Host "SharePoint Snapin loaded.`r`n" } } else { # The snapin was already added Write-Host "SharePoint Snapin detected.`r`n" } } |
Then just call the function in your script with Check-SPSnapin.
The script is self documented but if you have any problems, please ask.
Thanks,
Luke
Creatе а clone оf her іn this gamеǃǃ! http://defriponsfilmfoot.ga/prd-51023/
Аnd fuсk hеr withоut limіts, аѕ уоu alwауѕ wanted. She wоn’t rеfusе уouǃ
Ιf уou want, fuсk nоt оnly hеr, but alѕо her girlfrіend. Ѕimultаnеоuѕly!
… or mаybе уou want her tо fuck you?
На сайте представлено актуальное рабочее зеркало букмекерской конторы 1win для удобного доступа к ставкам и онлайн-играм вне зависимости от блокировок провайдеров.
используйте зеркало казино пинко для удобного доступа к играм и бонусам в любое время
Ищете доступ к сайту бк олимп бет в Казахстане? Узнайте как попасть на официальный сайт букмекерской конторы и начать делать ставки на спорт с выгодными коэффициентами.
Автоэлектроника для безопасности и комфорта — купить в ParkCam с доставкой
паркам интернет магазин
Hello folks I recently discovered a helpful site that made things so much easier. It’s focused on finding trusted platforms. The website offers great comparisons and gave me exactly what I needed. If you’re in need of some inspiration this is definitely worth checking out: casinosedge. Check it out and share your thoughts.