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
| # pluralOf - add plural 's' only if array contains more than 1 element | |
| # | |
| # example usage: | |
| # | |
| # Write-Host "Found $($computers.Count) computer$(pluralOf($computers))" | |
| # | |
| function pluralOf($inputObject) { | |
| if ($inputObject -is [System.Array] -or $inputObject -is [System.Collections.ArrayList]) { | |
| Write-Output "$($inputObject.Count -ne 1 ? 's' : '')" |
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 New-wpfProgressBar { | |
| param( | |
| [string] $WindowTitle = 'Progress', | |
| [int] $WindowWidth = 450, | |
| [int] $WindowHeight = 140, | |
| [string] $Text = "Processing...", | |
| [switch] $IsIndeterminate, | |
| [switch] $ShowPercentage, | |
| [switch] $Topmost | |
| ) |
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 Write-LogMessage{ | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter()] | |
| [string] $Message, | |
| [Parameter()] | |
| [string] $LogType = 'Info' | |
| ) |
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 Test-ExistInEnvPath($fileName) { | |
| $envPaths = ($env:Path -split ';') | Where-Object {$_ -ne ''} | |
| $envPaths | ForEach-Object { | |
| if (Test-Path -Path (Join-Path -Path $_ -ChildPath $fileName)) { | |
| Write-Output $true | |
| } else { | |
| Write-Output $false | |
| } | |
| } | |
| } |
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 Copy-FileWithStructure($Path,$Destination) { | |
| $fileObject = Get-Item -Path $Path | |
| $pathParts = ($fileObject.Directory.ToString()).split([System.IO.Path]::DirectorySeparatorChar) | |
| $newDestination = Join-Path -Path $Destination -ChildPath (($pathParts | Select-Object -Skip 1) -join([System.IO.Path]::DirectorySeparatorChar)) | |
| $script:newPath = $Destination | |
| # Loop through and re-create the folder structure | |
| foreach ($pathPart in ($pathParts | Select-Object -Skip 1)) { | |
| $newPath = Join-Path -Path $newPath -ChildPath $pathPart | |
| if (-not(Test-Path -Path $newPath)) { |
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 New-Thread { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(ValueFromPipeline)] | |
| [scriptblock] $Script, | |
| # Timeout in seconds | |
| [Parameter()] | |
| [int] $TimeOut = 60 | |
| ) |
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 Get-ADUserTokenGroups { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Position = 0, ValueFromPipeline)] | |
| [ValidateNotNullOrEmpty()] | |
| [Alias('u','User')] | |
| [string] $ADUserName = $env:USERNAME | |
| ) | |
| try { | |
| Add-Type -AssemblyName System.DirectoryServices.AccountManagement |
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
| DNS_NAME="some.domain.tld" | |
| openssl s_client -connect ${DNS_NAME}:443 -servername ${DNS_NAME} 2>/dev/null </dev/null | openssl x509 -noout -dates -issuer -subject |
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 Get-CertInfoHttp { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Position = 0, Mandatory)] | |
| [string] $URL, | |
| [Parameter()] | |
| [switch] $ReturnCertificate | |
| ) |
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 Get-CertInfoTcp { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Position = 0, Mandatory)] | |
| [string] $ComputerName, | |
| [Parameter(Position = 1)] | |
| [int] $Port = 443, | |
| [Parameter()] |
NewerOlder