This file contains hidden or 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 paralleltest | |
{ | |
$a = 1..10 | |
#Divide the 10 iterations into 3 (+1) blocks | |
foreach -parallel -throttlelimit (($a.count)/3) ($b in $a) | |
{ | |
Write-Output $b | |
} |
This file contains hidden or 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
#A hashtable converted into a json string can be converted back to hashtable like so: | |
#Create a hashtable, convert to json | |
$hash = @{"Name1"="Value";"Name2"="Value2"} | |
$json = $hash | ConvertTo-Json | |
#Take the json string and convert it back: | |
$newobject = $json | ConvertFrom-Json | |
$newhash = @{} | |
foreach ($prop in $newobject.psobject.Properties) |
This file contains hidden or 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 set-MITPrestageADComputer | |
{ | |
Param ( | |
[String]$CompName, | |
[string]$OU, | |
$Credential | |
) | |
Write-Output "Prestaging computer $CompName, OU $OU" | |
This file contains hidden or 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
#Replace PSComputerName with a remote host | |
workflow FooNoError | |
{ | |
param($CompName) | |
InlineScript { | |
$compName = $using:compName; | |
"Got $compName" | |
} -PSComputerName trondcloudDC | |
} |
This file contains hidden or 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
Param ( | |
[string]$SubjectName = $env:COMPUTERNAME, | |
[int]$CertValidityDays = 365, | |
$CreateSelfSignedCert = $true | |
) | |
#region function defs | |
Function New-LegacySelfSignedCert | |
{ |
This file contains hidden or 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
$Folders = get-childitem *db* -path "D:\MDB" -Recurse | |
foreach ($folder in $folders) | |
{ | |
$DBName = $folder.Name | |
$ExchangeServer = $DBName.split("-")[0] | |
$LogFolderPath = $folder.Fullname.Replace("DB","LOG") | |
$edbfilepath = "$($folder.FullName)\$DBName.edb" | |
if (!(get-mailboxdatabase $DBName -erroraction 0)) | |
{ |
This file contains hidden or 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
#!powershell | |
# This file is part of Ansible. | |
# | |
# Copyright 2014, Trond Hindenes <[email protected]> and others | |
# | |
# Ansible is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# |
This file contains hidden or 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
# Check if reboot is required. The MSFT_ServerManagerTasks provider is missing on client SKUs | |
$featureData = invoke-wmimethod -EA Ignore -Name GetServerFeature -namespace root\microsoft\windows\servermanager -Class MSFT_ServerManagerTasks | |
if($featureData -and $featureData.RequiresReboot) | |
{ | |
Write-Verbose "Computer needs a reboot" | |
} |
This file contains hidden or 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
#Configure the environment | |
$smawebserviceurl = "https://trondcloud-cs.cloudapp.net" | |
$smacreds = get-credential | |
#Set up two test runbooks, one referenced by the other (testwf1 references testwf2) | |
$TestWF1 = @" | |
workflow testwf1 | |
{ |
This file contains hidden or 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 Process-RunbookFolder | |
{ | |
Param ( | |
$Path, | |
[switch]$recurse | |
) | |
$allwfs = get-childitem -Path $Path -Recurse:$recurse | |
$Global:referencelist = New-Object System.Collections.ArrayList | |
[System.Collections.ArrayList]$Global:ToProcessList = $allwfs | select -ExpandProperty Fullname | |
$Global:DoneProcessList = New-Object System.Collections.ArrayList |
OlderNewer