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
$cred = Get-Credential | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection | |
Import-PSSession $Session |
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
Import-Module MSOnline -EA 0 | |
$credential = Get-Credential | |
Connect-MsolService -Credential $credential | |
$accountSKU = Get-MsolAccountSku | ? { $_.AccountSKUID -like "*ENTERPRISEPACK" } | |
$users = Get-MsolUser -All | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, Department -ExpandProperty Licenses | ? { $_.AccountSKUID -eq $accountSKU.AccountSkuID } |
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
# Specifies the URL for your organization's SPO admin service | |
$AdminURI = "https://tenantname-admin.sharepoint.com" | |
# Specifies the User account for an Office 365 global admin in your organization | |
$AdminAccount = "" | |
$AdminPass = "" | |
# Specifies the location where the list of MySites should be saved | |
$LogFile = "~\Desktop\MySites.txt" |
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
protected void Page_Load( object sender, EventArgs e ) | |
{ | |
if (!this.IsPostBack) | |
{ | |
// Extract the username fromt he query string and set the username TextBox | |
string url = Context.Request.Url.AbsoluteUri; | |
System.Collections.Specialized.NameValueCollection parameters = System.Web.HttpUtilitiy.ParseQueryString(url); | |
string userName = parameters["username"]; | |
if (!String.IsNullOrEmpty(userName)) |
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
######################################################################## | |
# 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
Get-MsolUser -All | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, Department -ExpandProperty Licenses | Export-Csv c:\LicensedUsers.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
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
with fs | |
as | |
( | |
select database_id, type, size * 8.0 / 1024 size | |
from sys.master_files | |
) | |
select | |
name, | |
(select sum(size) from fs where type = 0 and fs.database_id = db.database_id) DataFileSizeMB, | |
(select sum(size) from fs where type = 1 and fs.database_id = db.database_id) LogFileSizeMB |
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-SPDatabase | ForEach-Object {$db=0} {$db +=$_.disksizerequired; $_.name + " - " + $_.disksizerequired/1024/1024} {Write-Host "`nTotal Storage (in MB) =" ("{0:n0}" -f ($db/1024/1024))} | Out-File c:\temp\spdatabasesizes.txt |