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
# Qualified Function for unlocking an AD account | |
function unlock-anaccount { | |
<# | |
.SYNOPSIS | |
Used to unlock an AD account | |
.DESCRIPTION | |
Using the provided logon name this function will attempt to unlock the AD account. | |
.PARAMETER logonName | |
This value should match the User Account samAccountName aka User Logon Name from AD Users and Computers. | |
.EXAMPLE |
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
"PS Custom Object": { | |
"prefix": "pscustom", | |
"body": [ | |
"$$obj = [pscustomobject]@{", | |
"\tFieldName = FieldValue;", | |
"}" | |
], | |
"description": "Skeleton for adding a PowerShell Custom Object" | |
}, |
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
# Example of an inline filter and then a calculated expression | |
get-adcomputer -Filter {OperatingSystem -like "*Server*" -AND Name -like "PIT*"} | | |
Select-Object Name,@{n="online";e={test-connection -Computer $_.Name -Count 1 -Quiet}} |
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
$file = 'C:\etc\srv03sb.csv' | |
$computers = Import-Csv -Path $file -Header ComputerName, IPAdress, DNSServer1, DNSServer2, DNSServer3 | |
foreach ($computer in $computers) { | |
if(Test-Connection -ComputerName $computer.ComputerName -Count 1 -ea 0) { | |
try { | |
$Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $computer.ComputerName -EA Stop | ? {$_.IPEnabled} | |
} | |
catch { | |
Write-Warning "Error occurred while querying $computer." |
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 Publish-admcred { | |
Begin{ | |
$path = "$home\Desktop\mycred.json" | |
# Remove existing cred file if exists | |
if (test-path $path){Remove-Item $path -force} | |
} | |
Process{ | |
$cred = Get-Credential | |
$cred | | |
Select Username,@{n="Password"; e={$_.password | ConvertFrom-SecureString}} | |
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
{ | |
"Condition statement": { | |
"prefix": "cond", | |
"body": [ | |
"${_} { ${0}; break }" | |
], | |
"description": "Switch condition statement" | |
}, | |
"Credential Parameter": { | |
"prefix": "credparam", |
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 show-installedmodules { | |
<# | |
.SYNOPSIS | |
Lists Installed Modules and compares installed versions compared to online version | |
.DESCRIPTION | |
Uses list of installed modules via Get-InstalledModule, and compares them to current online version using | |
the Find-Module returned Version. Place in profile to ensure it is loaded in all PowerShell sessions is | |
recommended. | |
.EXAMPLE | |
I ♥ PS > show-installedmodules |
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 show-installedmodules { | |
<# | |
.SYNOPSIS | |
Lists Installed Modules and compares installed versions compared to online version | |
.DESCRIPTION | |
Uses list of installed modules via Get-InstalledModule, and compares them to current online version using | |
the Find-Module returned Version | |
.EXAMPLE | |
I ♥ PS > show-installedmodules | |
Example of how to use this Function |
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 show-installedmodules { | |
#Requires -Version 5 | |
[CmdletBinding()] | |
Param( | |
$varModules = (get-installedmodule) | |
) | |
Begin { | |
"-" * 52 | |
"`tReporting on {0} modules" -f $varModules.Count | |
"-" * 52 |
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
<# | |
.SYNOPSIS | |
Installs base VSCode Extensions | |
.DESCRIPTION | |
Uses list of recommended extensions to start using VSCode with PowerShell. | |
.NOTES | |
=========================================================================== | |
Created with: Visual Studio Code | |
Created on: 08.12.2018 | |
Created by: Kavanagh, John J. |
OlderNewer