Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Sean O'Sullivan seanosullivanuk

👋
View GitHub Profile
@seanosullivanuk
seanosullivanuk / adcomputerexport.ps1
Created Aug 11, 2020
Export all Computer records from Active Directory to a CSV
View adcomputerexport.ps1
Import-Module ActiveDirectory
Get-ADComputer -Filter * -Properties * |
Select -Property Name,DNSHostName,Enabled,Description |
Export-CSV "C:\Temp\AllComputers.csv" -NoTypeInformation -Encoding UTF8
@seanosullivanuk
seanosullivanuk / passmandatoryparameter.ps1
Created Apr 13, 2019
Pass a mandatory parameter to a PowerShell script
View passmandatoryparameter.ps1
# Pass a mandatory parameter to a PowerShell script
# This example requests a single string, stored as a variable
# e.g. .\passmandatoryparameter.ps1 -FavouriteColour Purple
# If the parameter isn't provided (e.g. .\passmandatoryparameter.ps1), the script will request it,
# but if nothing is passed the script will throw an error.
param(
[Parameter(Mandatory=$true)]
[string]$FavouriteColour
@seanosullivanuk
seanosullivanuk / passparameter.ps1
Created Apr 13, 2019
Pass a parameter to a PowerShell script
View passparameter.ps1
# Pass a parameter to a PowerShell script
# This example requests a single string, stored as a variable
# e.g. .\passparameter.ps1 -FavouriteColour Purple
# If the parameter isn't provided (e.g. .\passparameter.ps1), the script will request it
param (
[string]$FavouriteColour = "$(Read-Host 'Tell me your favourite colour')"
)
@seanosullivanuk
seanosullivanuk / sign.md
Created Oct 19, 2018
Sign PowerShell scripts (Windows)
View sign.md

First, check the code signing certificate(s) are present in the Personal Store:

gci cert:\CurrentUser\My -codesigning

To sign, run the following code block:

$acert =(dir Cert:\CurrentUser\My -CodeSigningCert)[0]
Set-AuthenticodeSignature .\FileName.ps1 -Certificate $acert -TimestampServer http://timestamp.comodoca.com/authenticode
You can’t perform that action at this time.