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
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 |
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-Star | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[ValidateSet('Option1','Option2','Option3','*')] | |
[ValidateScript({ ($_ -contains '*' -and $_ -isnot [array]) -or ($_ -notcontains '*') })] | |
$StarParam | |
) | |
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 an enum with All constant | |
Add-Type -TypeDefinition @' | |
using System; | |
[Flags] | |
public enum O365Services | |
{ | |
AzureActiveDirectory, | |
Exchange, | |
Sharepoint, |
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
gwmi CIM_operatingsystem|Select PSC*,*j*,v*,@{n='BIOSSerial';e={$_.SerialNumber}} |
OlderNewer