View Test-AzureARMTemplateDeployment.ps1
$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
View Split-AdUsersByDepartmentIntoSeperateVariables.ps1
$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 }
}
View Get-EventLogLoginIp.ps1
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
View Get-MailboxFolderStatistics.ps1
Get-MailboxFolderStatistics test@test.com | Select-Object name, @{
Name="FolderSize";
Expression={
[math]::Round(([regex]::matches($_.FolderSize,'\(([^\}]+)\)').value -replace 'bytes', '' -replace '\(', '' -replace '\)', '' -replace ',', '') / 1MB, 2)
}
} | Sort-Object FolderSize -Descending
View vmExtension.azuredeploy.json
{
"$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"
}
}
View Get-VMIdFromJobId.ps1
workflow Get-VMIdFromJobId {
param(
    [Parameter(Mandatory=$true)]
    [STRING]$VMMJobId    
    )
    #Get VMM Connection Object
    $vmmcon = Get-AutomationConnection -Name "SCVMM"
    #Construct the VMM Credential