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-MsolUserLicense | |
{ | |
[CmdletBinding(DefaultParameterSetName='SetUserLicenses__0', SupportsShouldProcess=$true)] | |
param | |
( | |
[Parameter(ParameterSetName='SetUserLicenses__0', Mandatory=$true, ValueFromPipelineByPropertyName=$true)] | |
[guid] | |
$ObjectId, | |
[Parameter(ParameterSetName='SetUserLicensesByUpn__0', ValueFromPipelineByPropertyName=$true)] | |
[Parameter(ParameterSetName='SetUserLicenses__0', ValueFromPipelineByPropertyName=$true)] |
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-GPOStatus | |
{ | |
<# | |
.Synopsis | |
Set the status of a Group Policy Object | |
.Description | |
Sets the status of one or more Group Policy objects. | |
.Example | |
PS C:\> Get-Gpo MyGPO | Set-GPOStatus -Status AllSettingsEnabled | |
.Example |
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 Test-ConditionalParameter | |
{ | |
param | |
( | |
[validateset('Value1','Value2')] | |
[parameter()] | |
$Parameter1 | |
) | |
dynamicparam |
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
<# | |
.SYNOPSIS | |
This script disjoins a computer from an Active Directory domain, performs a reboot and upon coming back up | |
joins it to the domain again and performs another reboot. | |
.NOTES | |
Requirements: You must have local admin rights on the remote computer to connect to the remote computer | |
.PARAMETER Computername | |
The name of the computer to rejoin to a domain | |
.PARAMETER DomainName | |
The NetBIOS or FQDN of the domain to rejoin the computer to |
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 Test-BeginBlock | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[parameter(ValueFromPipeline)] | |
$Parameter1 | |
) | |
begin { $Variable1 = 'whatev' } |
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
$null = Register-ObjectEvent -InputObject $psISE.PowerShellTabs.SelectedPowerShellTab -EventName 'PropertyChanged' -Action { | |
if($args[1].PropertyName -eq 'LastEditorWithFocus' -and $env:AutoChangeLocation -eq $true) | |
{ | |
$Location = Get-Location | |
$NewLocation = split-path $psISE.PowerShellTabs.SelectedPowerShellTab.Files.SelectedFile.FullPath | |
if ($Location.path -ne $NewLocation) | |
{ | |
Set-Location $NewLocation | |
Out-Host -InputObject ' ' | |
prompt |
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
# Indent style for multiline hashtables | |
# I tend to think of the assignment and opening '@{' as | |
# one token. | |
$Capabilities = @{ | |
MilitaryService = $false | |
DrinkAlcohol = $false | |
Vote = $false | |
} | |
# This usage works nearly everywhere for me |
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
$Credential = Get-Credential | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Credential -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
# Connect to Azure Active Directory to manage users, groups and licensing | |
Connect-MsolService -Credential $Credential | |
# Connect to Sharepoint Online for domain psescape.onmicrosoft.com | |
Connect-SpoService -Credential $Credential -Url https://psescape-admin.sharepoint.com | |
# Connect to Lync Online | |
$Session = New-CsOnlineSession -Credential $Credential | |
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
Connect-O365 -Services AzureActiveDirectory, Exchange, Sharepoint, Skype -Credential $Credential |
OlderNewer