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
$TenantId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # Replace with your tenant ID | |
# If you don't need to specify a tenant ID, replace with the next comment | |
# $Subs = Get-AzSubscription | |
$Subs = Get-AzSubscription -TenantId $TenantId | |
$results = foreach ($Sub in $Subs) { | |
Set-AzContext -SubscriptionId $Sub.Id | Out-Null | |
Write-Host -Message "====== Switching to subscription: $($Sub.Name)" | |
Write-Host -Message "====== Subscription ID: $($Sub.Id)" |
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
$Result = foreach ($User in $Users) { | |
# Logic for checking users here, blah, blah... | |
# We want a [pscustomobject] for each successful check. | |
# Notice how we just throw the object out there... This is sending output to the success stream (Get-Help about_Output_Streams). | |
# It'll get picked up by $Result once the loop finishes iterating. | |
[pscustomobject]@{ | |
Prop1 = $User.Prop1 | |
Prop2 = $User.Prop2 |
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
$numbers = foreach ($i in 1..10) {"{0:d2}" -f $i} | |
foreach ($num in $numbers) { | |
$UserToCheck = "{0}{1}" -f $UserFromSql, $num | |
Get-ADUser -Identity $UserToCheck | |
} |
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
$thisIsAString += "one" | |
$thisIsAString += "two" | |
$thisIsAString += "three" | |
$thisIsAString | |
# onetwothree | |
$thisIsAString.gettype() | |
# IsPublic IsSerial Name BaseType | |
# -------- -------- ---- -------- |
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
$csv = @' | |
Column1,Column2,Column3 | |
Name1,Mailbox1,Value1 | |
Name2,Mailbox2,Value2 | |
Name3,Mailbox3,Value3 | |
'@ | ConvertFrom-Csv | |
$Count = 1 | |
foreach ($row in $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
[array]$MachineArray = foreach ($Machine in $Group.Value.migratename) { | |
"/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Migrate/projects/{2}/machines/{3}?api-version=2018-02-02" -f $SubscriptionId, $RgName, $ProjectName, $Machine | |
} | |
$Body = @{ | |
properties = @{ | |
machines = $MachineArray | |
} | |
} |
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
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[ValidateScript({ | |
if (-not (Test-Path $_)) { | |
throw "File or folder does not exist" | |
} | |
$true | |
})] | |
[System.IO.FileInfo] |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<Configuration> | |
<SelectionSets> | |
<SelectionSet> | |
<Name>FormattedCounter</Name> | |
<Types> | |
<TypeName>IronScripter.FormattedCounter</TypeName> | |
</Types> | |
</SelectionSet> | |
</SelectionSets> |
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 Get-FormattedCounter { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory, | |
ValueFromPipeline)] | |
[Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet[]] | |
$Counter | |
) | |
process { |
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 Recover-LogSpace | |
{ | |
[CmdletBinding()] | |
Param( | |
[parameter(ParameterSetName='Multiple')] | |
[parameter(ValueFromPipelineByPropertyName=$true, | |
ParameterSetName='Single')] | |
[string[]]$SqlServer, | |
[parameter(ValueFromPipelineByPropertyName=$true, |
NewerOlder