Get-SPShellAdmin
If your current user doesn't have enough permissions you can grant ShellAdmin rights by running:
Add-SPShellAdmin -UserName <domain>\<username> -database <DB Name>
See these pages for more information:
Get-SPShellAdmin
Add-SPShellAdmin -UserName <domain>\<username> -database <DB Name>
$mySite_url = <Url to your My Site site collection>; $context = Get-SPServiceContext $mySite_url; $upm= New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context); Write-Host($upm.Count);
$profiles = $upm.GetEnumerator();
$profiles.Reset();
$count = 0;
foreach($profile in $profiles) {$count++;}
Write-Host($count);
$masterPageGallery = "Master Page Gallery"
$url = "http://www.example.com"
$site = Get-SPSite $url
$list = $site.RootWeb.Lists[$masterPageGallery]
foreach($item in $list.Items)
{ Write-Host $item.Name "-" $item.File.CustomizedPageStatus
$root_dir="path to backups";Backup-SPSite –Identity http://domain.tld/sites/test -Path $root_dri+"\test.bak"
$root_dir="path to backups"; Backup-SPSite –Identity http://domain.tld/sites/test -Path $root_dri+"\test.bak"
$root_dir = "path to backups"
Get-SPSite | ForEach-Object
$FilePath = $root_dir + $_.Url.Replace("http://","").Replace(https://,"").Replace("-","--").Replace("/","-").Replace(";","-") + ".bak";
Backup-SPSite –Identity $_.Url -Path $FilePath;
}
$root_dir="path to backups"; Get-SPSite | ForEach-Object{$FilePath = $root_dir + $_.Url.Replace("http://","").Replace(https://,"").Replace("-","--").Replace("/","-").Replace(";","-") + ".bak"; Backup-SPSite –Identity $_.Url -Path $FilePath}
$packages_folder = "packages"
$local_path = $(get-location)
$packages = [IO.Directory]::GetFiles("$local_path\$packages_folder");
write-host "Installing:"
foreach ($package in $packages) {
$package_withoutPath = $package.split('\')[-1];
$wspID = Get-SPSolution -Identity $package_withoutPath;
#wait here until the previously deployed package is finished with deployment
write-host " $package_withoutPath" -nonewline;
while($wspID.JobExists -eq $true) {
write-host '.' -nonewline;
sleep -Seconds:1;
}
write-host '';
Update-SPSolution -Identity $package_withoutPath -LiteralPath $package -GACDeployment;
}
write-host "Finishing:"
foreach ($package in $packages) {
$package_withoutPath = $package.split('\')[-1]
write-host " $package_withoutPath" -nonewline;
$wspID = Get-SPSolution -Identity $package_withoutPath;
while($wspID.JobExists -eq $true) {
write-host '.' -nonewline;
sleep -Seconds:1;
}
write-host '';
}