Skip to content

Instantly share code, notes, and snippets.

@morgansimonsen
morgansimonsen / gist:8039470
Created December 19, 2013 13:58
Count all CPU cores for subscription across all cloud services
# CountWACores.ps1
# Morgan Simonsen, www.cloudpower.no
# Count all CPU cores for subscription across all cloud services
$colVMs = @()
[int]$TotalCores = 0
$VMs = (Get-AzureService).servicename | foreach {Get-AzureVM -ServiceName $_ }
foreach ( $VM in $VMs )
@morgansimonsen
morgansimonsen / gist:8039845
Created December 19, 2013 14:23
List all Windows Azure availability sets and their VMs
(Get-AzureService).servicename | foreach {Get-AzureVM -ServiceName $_ } | select name,AvailabilitySetName
@morgansimonsen
morgansimonsen / gist:8039966
Created December 19, 2013 14:31
Opt in to Microsoft Update with PowerShell
$mu = New-Object -ComObject Microsoft.Update.ServiceManager -Strict
$mu.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")
@morgansimonsen
morgansimonsen / FindOutdatedComputers.vbs
Created December 19, 2013 14:34
Find outdated computer Objects in Active Directory
' FindOutdatedComputers.vbs
' by Morgan Simonsen
' http://morgansimonsen.wordpress.com
'
' This script will search an Active Directory domain for computer accounts that have
' not logged on the domain in the specified time limit (default 60 days).
'
' 600 000 000 100-nanosecond intervals in 1 minute
' 1440 minutes in 24-hours
' 30 * 1440 * 600 000 000 = time in 100-nanosecond intervals since 1.1.1601
@morgansimonsen
morgansimonsen / gist:8040092
Last active January 10, 2022 11:53
OWA URL simplification with URL Rewrite
<rewrite>
<rewriteMaps>
<rewriteMap name="Exchange Server" />
</rewriteMaps>
<rules>
<clear />
<rule name="Redirect root (Exchange Server)" enabled="true" stopProcessing="true">
<match url="^$" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false" />
<action type="Redirect" url="/owa" appendQueryString="false" />
@morgansimonsen
morgansimonsen / gist:8040285
Created December 19, 2013 14:51
Remove Exchange attributes
get-qadobject -SearchRoot <canonical name of domain> ´
-ldapFilter '(&(objectClass=group)(mailnickname=*))' ´
-service <DC FQDN> -SizeLimit 0 | Set-QADObject -ObjectAttributes ´
@{adminDisplayName='';´
altRecipient='';´
authOrig='';´
autoReplyMessage='';´
deletedItemFlags='';´
delivContLength='';´
deliverAndRedirect='';´
@morgansimonsen
morgansimonsen / gist:8044861
Created December 19, 2013 19:35
Set non-expiring password for Office 365 users
Import-Module MSOnline
$MSOLCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $MSOLCred -Authentication Basic –AllowRedirection
Import-PSSession $Session
Connect-MsolService -Credential $MSOLCred
# Control-AzureVMs.ps1
# Shut down or start a set of Windows Azure VMs in sequence
# v0.1 2014-01-20
#
# Morgan Simonsen
# www.cloudpower.no
# morgansimonsen.wordpress.com
Select-AzureSubscription "<subscription name>"
03/11/2014 22:24:44:407 NetpDoDomainJoin
03/11/2014 22:24:44:407 NetpMachineValidToJoin: ‘SERVER1′
03/11/2014 22:24:44:407 OS Version: 6.2
03/11/2014 22:24:44:407 Build number: 9200 (9200.win8_gdr.130531-1504)
03/11/2014 22:24:44:407 SKU: Windows Server 2012 Datacenter
03/11/2014 22:24:44:407 Architecture: 64-bit (AMD64)
03/11/2014 22:24:44:407 NetpDomainJoinLicensingCheck: ulLicenseValue=1, Status: 0x0
03/11/2014 22:24:44:407 NetpGetLsaPrimaryDomain: status: 0x0
03/11/2014 22:24:44:407 NetpMachineValidToJoin: status: 0x0
03/11/2014 22:24:44:407 NetpJoinDomain
@morgansimonsen
morgansimonsen / aadb2cclaimsprovider.xml
Created February 28, 2017 11:34
Azure AD External IdP for Azure AD B2C
<ClaimsProvider>
<DisplayName>External Azure Active Directory</DisplayName>
<TechnicalProfiles>
<TechnicalProfile Id="ExternalAzureActiveDirectory-OpenIdConnect">
<DisplayName>Azure Active Directory</DisplayName>
<Protocol Name="OpenIdConnect" />
<OutputTokenFormat>JWT</OutputTokenFormat>
<Metadata>
<Item Key="METADATA">https://login.windows.net/<insert-tenant-id>/.well-known/openid-configuration</Item>
<Item Key="ProviderName">https://sts.windows.net/<insert-tenant-id>/</Item>