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
<# | |
List taken from SO answer: | |
http://stackoverflow.com/questions/4730152/what-indicates-an-office-open-xml-cell-contains-a-date-time-value | |
#> | |
$ExCellStyles = @{ | |
0 = 'General' | |
1 = '0' | |
2 = '0.00' | |
3 = '#,##0' |
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 ConvertFrom-SID { | |
param ( | |
[Parameter(Position = 0, Mandatory = $True)] | |
[String] | |
[ValidateNotNullOrEmpty()] | |
$SID | |
) | |
$AccountSIDInstance = Get-CimInstance -ClassName Win32_AccountSID -Filter "Setting = 'Win32_SID.SID=`"$SID`"'" |
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
#Requires -Modules ActiveDirectory | |
function Get-ADUserPasswordExpiration | |
{ | |
param( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] | |
[Alias('DistinguishedName')] | |
[Microsoft.ActiveDirectory.Management.ADUser[]]$Identity | |
) |
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
$Properties = 'employeeID' | |
# Retrieve all workers with their "manager" attribute | |
Get-ADUser -Filter "title -like '*worker*'" -Properties @('manager';$Properties) |ForEach-Object { | |
# Iterate over workers, retrieve each workers manager individually | |
[pscustomobject]@{ | |
Worker = $_ | |
Manager = Get-ADUser -Identity $_.manager -Properties $Properties -ErrorAction SilentlyContinue | |
} | |
} |
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
$source = "C:\LabResources\xTimeZone" | |
$destination = "C:\temp" | |
$Version = (Get-ChildItem -Path $source -Depth 1).Name | |
$ResoureName = (Get-ChildItem -Path $source -Depth 1).Parent.Name | |
$ModuleName = $ResoureName+'_'+$Version | |
New-Item -Path ($destination+'\'+$ModuleName) -ItemType Directory |
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-WSManTrust { | |
(Get-Item -Path WSMan:\localhost\Client\TrustedHosts | % Value).split(',') | |
} | |
function New-WSManTrust { | |
param( | |
[string]$hostname | |
) | |
Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value $hostname -Concatenate -Force | |
} |
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-AzSpotPrice { | |
[CmdletBinding()] | |
param ( | |
#VM SKU (e.g. Standard_F8s) | |
[String]$Sku, | |
#Azure Region (e.g. brazilsouth) | |
[String]$Region, | |
#ODATA filter to use on the data | |
[String]$Filter, | |
#Maximum number of records to retrieve, or specify 'Unlimited' for all records. Defaults to 100. This behaves like the Exchange Cmdlets |
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
# Example code of running multiple Pester test in parallel and merging the result into one NUnitReport Test Report file | |
#region Run Pester Test scripts in parallel | |
$job = Get-ChildItem -Path "./tests" -Filter "Demo*" | |
| ForEach-Object -Parallel { | |
Invoke-Pester -Path $_ -PassThru | |
} -ThrottleLimit 10 -AsJob | |
$Results = ($job | Wait-Job | Receive-Job -Keep) | |
#endregion |
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 ConvertTo-Base64KMSEncryptedString { | |
[CmdletBinding()] | |
param ( | |
[Parameter( | |
Mandatory = $true, | |
ValueFromPipeline = $true | |
)] | |
[String[]] | |
$String, |
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 Open-GHWebEditor { | |
<# | |
.SYNOPSIS | |
Opens the GitHub web editor on a repo. | |
.EXAMPLE | |
Open-GHWebEditor powerShell/powerShell | |
#> | |
param( | |
[Parameter(Mandatory)] |
OlderNewer