This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue | |
foreach ($WebApp in (Get-SPWebApplication)) { | |
"Testing Web Application - " + $WebApp.Name | Write-Host -ForegroundColor Green; | |
foreach ($CDB in $WebApp.ContentDatabases) { | |
Test-SPContentDatabase -Name $CDB.Name -WebApplication $WebApp.URL -ServerInstance $CDB.Server | ConvertTo-Csv | Out-File -Encoding default -FilePath $("C:\temp\" + $CDB.Name + ".csv") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-SPUIVersion( | |
[string]$dbName = $(Read-Host -prompt "Content Database Name"), | |
[int32]$uiVersion = $(Read-Host -prompt "UI Version")) | |
{ | |
$db = Get-SPContentDatabase $dbName | |
foreach ($s in $db.Sites) { | |
foreach ($w in $s.AllWebs) { | |
$w.UIversion = $uiVersion; | |
switch ($uiVersion) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-SPFarmSolutions { | |
param ( | |
[string] $directory = $(Read-Host -prompt "Enter a directory (use ""."" for current dir)") | |
) | |
if ($directory.Length -lt 2) { | |
$directory = [string]$pwd + "\\"; | |
} | |
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psconfig -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") | |
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") | |
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | |
# Enter your SharePoint site URL here... | |
$site = new-object Microsoft.SharePoint.SPSite("http://intranet"); | |
$web = Get-SPWeb "http://intranet"; | |
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.SharePoint.PowerShell | |
$siteUrl = "http://mycoolsite/" | |
$accountName = "MyAccountName" | |
$site = Get-SPSite $siteUrl | |
$context = Get-SPServiceContext($site) | |
$pm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) | |
# If user profile doesn't exist create new one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$webappName = “http://intranet.contoso.com” | |
$backupDir = “C:\backups” | |
Write-Host "Backing up $webappName web.config file…" -foreground Gray –nonewline | |
## Get the web application – by display name | |
$w = Get-SPWebApplication | where { $_.DisplayName -eq "$webappName"} | |
## Get the default (first) zone for the web app… | |
## You may wish to iterate through all the available zones |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################## | |
# Connect to an Azure subscription | |
######################################################################## | |
Login-AzureRmAccount | |
# Select your subscription if required | |
Select-AzureRmSubscription -SubscriptionId "yoursubscriptionid" | |
######################################################################## | |
# Copy a Vhd from an existing storage account to a new storage account |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -Version 2 -Modules ActiveDirectory | |
Get-ADOrganizationalUnit -Filter * | | |
ForEach-Object { | |
$OU = $_ | |
Get-ADComputer -Filter * -SearchBase $OU.DistinguishedName -SearchScope SubTree -Properties Enabled, OperatingSystem | | |
Where-Object { $_.Enabled -eq $true } | | |
Group-Object -Property OperatingSystem -NoElement | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-MsolUser -All | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, Department -ExpandProperty Licenses | Export-Csv c:\LicensedUsers.csv |