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
# Orginal Cert | |
$base64CertAsGetContentImported = @( | |
'-----BEGIN CERTIFICATE-----' | |
'MIIDPjCCAiagAwIBAgIQQuZ95xvR1p5DHeDuOzxbPzANBgkqhkiG9w0BAQsFADAb' | |
'MRkwFwYDVQQDDBB3d3cuZmFicmlrYW0uY29tMB4XDTIxMDUyNTA3MzAwNFoXDTIy' | |
'MDUyNTA3NTAwNFowGzEZMBcGA1UEAwwQd3d3LmZhYnJpa2FtLmNvbTCCASIwDQYJ' | |
'KoZIhvcNAQEBBQADggEPADCCAQoCggEBANs51YbaCyGdgduRTKAwqd2R9z0BwfH1' | |
'RuBzWP4imFNjvgmJDR4tII3ESng3udp3QqBu8ArdBVAZL0a5w+lJ9uhC8vD+pDGb' | |
'dtEqBi5fSzEMSGahVT+P8VqB2myVah9Ab6kuz5dGjtkIX7aoI3yId3Ji3lU8gtbv' | |
'U8Az5mxqhsDajl9BuUJCtVr02+i4WmbSLI3nzxFDXYJjJIVvrS/yxTzH7nuRud+d' |
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
$tmpFile = New-TemporaryFile | |
@" | |
DisplayName,Phone | |
Johan Akerstrom,0721234567 | |
Test Tester,0711234567 | |
"@ | Set-Content $tmpFile | |
#requires -version 5.1 |
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
# | |
# How to get help right for an array of PSTypeNames | |
# | |
# Awesome function to get some random stuff | |
# The important thing is that we get objects with an added PSTypeName of 'Stuff' | |
Function Get-Stuff { | |
[cmdletbinding()] | |
param( |
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
$definition = @' | |
using System; | |
using System.Runtime.InteropServices; | |
public class W32ShutdownUtil { | |
[DllImport("advapi32.dll", SetLastError = true)] | |
public static extern bool AbortSystemShutdown(String machineName); | |
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)] | |
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen); |
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
While ( $True ) { $PSise.Options.Zoom = 100 + 10 * [math]::sin( (Get-Date).TimeOfDay.TotalSeconds ); Sleep -Milliseconds 40 } |
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-ADGroupMemberSamAccountName { | |
param( | |
[Parameter(Mandatory,ValueFromPipeline)] | |
[ValidateNotNullOrEmpty()] | |
[string]$GroupName | |
) | |
process { | |
$name = $GroupName | |
$domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() | |
$dc = $domain.FindDomainController([System.DirectoryServices.ActiveDirectory.LocatorOptions]::WriteableRequired) |
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
$Name = "MSFT-Office 365 Enterprise E1" | |
$groupSearcher = [adsisearcher]"(samaccountname=$Name)" | |
$group = $groupSearcher.FindOne() | |
$memberSearch = [adsisearcher]::new($group.GetDirectoryEntry(),"(&(objectClass=user)(objectCategory=Person))",[string[]]'samaccountname','base') | |
$memberSearch.AttributeScopeQuery = "member"; | |
foreach($member in $memberSearch.FindAll()) | |
{ | |
$member.Properties['samaccountname'] | |
} |
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
# DropDown Data | |
$office = @{ | |
'HQ' = 'Ground floor','1st floor','2nd floor','3rd floor' | |
'Garage' = 'Shop floor','Office' | |
'Sales office' = 'Ground floor','1st floor' | |
} | |
# Load assemblies | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") |
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-CertificateChain { | |
param( | |
[string]$server=$(throw "Mandatory parameter -Server is missing."), | |
[int]$port=$(throw "Mandatory parameter -Port is missing."), | |
[switch]$ToBase64 | |
) | |
$code=@" | |
using System; | |
using System.Collections; | |
using System.Net; |
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
Write-Host "Done Name State HasData" | |
$global:js = [System.Collections.ArrayList]::new() | |
for($i=0;$i -lt 10;$i++){ | |
$j = Start-Job {"JOB" + $using:i;Start-Sleep -Milliseconds (Get-Random -Maximum 3000 -Minimum 0) } -Name "MyJob-$i" | |
$j | Add-Member -Name CursorTop -MemberType NoteProperty -Value ([console]::CursorTop) -Force | |
[void]$js.Add($j) | |
Write-Host "x " -ForegroundColor Red -NoNewline | |
Write-Host ("{0} {1} {2}" -f $j.Name,$j.State,$j.HasMoreData) | |
} | |
[console]::CursorVisible = $false |
NewerOlder