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
$currentContext = Get-AzContext | |
$azureRmProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile | |
$azureRmProfileClient = [Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient]::new($azureRmProfile) | |
$azureRmProfileClient.AcquireAccessToken($currentContext.Subscription.TenantId) |
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
$vstsTasks = @( | |
"##vso[task.setvariable variable=foo]bar" | |
"##vso[task.setvariable variable=for ]bar" | |
"##vso[task.setvariable variable=for] bar" | |
"##vso[ task.setvariable variable=for]bar" | |
"##vso [task.setvariable variable=for]bar" | |
) | |
Describe "VSTS" { | |
Context "Fake Lint" { |
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
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"vmNames": { | |
"type": "array", | |
"defaultValue": [ | |
"vm1", | |
"vm2" | |
], |
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
$templatesFolderPath = Get-ChildItem -Path (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace('tests\unit', 'src') | Where-Object { $_.PSIsContainer -eq $true } | |
Describe "Test Template Againsts Endpoint" -Tags 'unit' { | |
foreach($templateFolderPath in $templatesFolderPath) | |
{ | |
Context "Does The Template Deploy Correctly" { | |
$hashReturn = @{} | |
$ParametersObject = Get-Content -Path (Join-Path $templateFolderPath.FullName 'azuredeploy.parameters.json') | ConvertFrom-Json |
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
$adUsers = Get-AdUser -Filter * -Properties name, department | |
$uniqueDepartments = $adUsers | Where-Object { $_.department -ne $null } | Select-Object -ExpandProperty department -Unique | |
foreach ($uniqueDepartment in $uniqueDepartments) { | |
$variableSplat = @{ | |
'Name' = ($uniqueDepartment -replace ' ', '') | |
'Value' = $adUsers | Where-Object { $_.department -eq $uniqueDepartment } | |
} |
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
Get-WinEvent -Logname Security -FilterXPath "*[System[EventID=4624]]" | Where-Object { $_.Properties[18].Value -ne '-' } | Select-Object MachineName, | |
@{ | |
Name = 'UserName' | |
Expression = { $_.Properties[5].Value } | |
}, | |
@{ | |
Name ='IP' | |
Expression = { $_.Properties[18].Value } | |
}, | |
TimeCreated | Sort-Object -Descending UserName |
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
Get-MailboxFolderStatistics [email protected] | Select-Object name, @{ | |
Name="FolderSize"; | |
Expression={ | |
[math]::Round(([regex]::matches($_.FolderSize,'\(([^\}]+)\)').value -replace 'bytes', '' -replace '\(', '' -replace '\)', '' -replace ',', '') / 1MB, 2) | |
} | |
} | Sort-Object FolderSize -Descending |
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
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"vmName": { | |
"type": "string", | |
"metadata": { | |
"description": "Name of the VM" | |
} | |
} |
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
workflow Get-VMIdFromJobId { | |
param( | |
[Parameter(Mandatory=$true)] | |
[STRING]$VMMJobId | |
) | |
#Get VMM Connection Object | |
$vmmcon = Get-AutomationConnection -Name "SCVMM" | |
#Construct the VMM Credential |