Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am morgansimonsen on github.
  • I am morgansimonsen (https://keybase.io/morgansimonsen) on keybase.
  • I have a public key ASCUOxntc2MXmp9MpWApjP4iTX5KSLJv-OnlBdnRVleHvAo

To claim this, I am signing this object:

<#
.SYNOPSIS
PowerShell script to add segment to IIS Request Filtering Hidden Segments
.DESCRIPTION
Specify the config element, website and the segment to add to the list of Hidden Segments
.PARAMETER ConfigFile
The IIS config element to apply the hidden segment to
ApplicationHost: system32\inetsrv\config\applicationhost.config global section
ApplicationHost: system32\inetsrv\config\applicationhost.config using the 'location' tag to target the website
WebConfig: the web.config file in the root of the website directory
# CopyManagedDisk.ps1
# Morgan Simonsen
# morgansimonsen.com
#
# Copies an Azure managed disk from one Azure region to another via a storage account
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1,
HelpMessage="Source resource group where the managed disk(s) to copy is.")]
@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>
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
# 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>"
@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
@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: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 / 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