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 -version 4.0 | |
Function New-GitHubGist { | |
[cmdletbinding(SupportsShouldProcess,DefaultParameterSetName = "Content")] | |
Param( | |
[Parameter(Position = 0, Mandatory, HelpMessage = "What is the name for your gist?",ValueFromPipelineByPropertyName)] | |
[ValidateNotNullorEmpty()] | |
[string]$Name, |
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
$domain = "domain name" | |
$username = "user name" | |
$User = $username + "@" + $domain | |
$Password = (Read-Host -asSecureString "Enter the current password") | |
$Credential = New-Object System.Management.Automation.PSCredential ($User, $Password) | |
Set-ADAccountPassword -Credential $Credential -Server $domain -Identity $userName -OldPassword $Password -NewPassword (Read-Host -asSecureString "Enter the new password") |
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
Show hidden characters
{ | |
"folders": [{ | |
"path": "." | |
}], | |
"settings": { | |
"powershell.codeFormatting.autoCorrectAliases": true, | |
"powershell.codeFormatting.openBraceOnSameLine": true, | |
"powershell.codeFormatting.useCorrectCasing": true | |
} | |
} |
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
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
Write-Host "Location: $PSScriptRoot" | |
Write-Host "Username: $env:UserName" | |
Set-Location $PSScriptRoot | |
$dataDir = "./mouse_manager_data" | |
# Get the ID and security principal of the current user account | |
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() |
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 DoStuff { | |
[CmdletBinding()] | |
param () | |
BEGIN | |
{ | |
$CMDOUT = @{ | |
Verbose = If ($PSBoundParameters.Verbose -eq $true) { $true } else { $false }; | |
Debug = If ($PSBoundParameters.Debug -eq $true) { $true } else { $false } | |
} |
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
$Users = get-aduser -Filter {admincount -gt 0} -Properties adminCount -ResultSetSize $null | |
$Users | Select-Object Name, UserPrincipalName, 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
#insert password here | |
$string = "Passw0rd!" | |
$encoding = [System.Text.Encoding]::UTF8 | |
$SHA1Hash = New-Object -TypeName "System.Security.Cryptography.SHA1CryptoServiceProvider" | |
$Hashcode = ($SHA1Hash.ComputeHash($encoding.GetBytes($string)) | ForEach-Object { "{0:X2}" -f $_ }) -join "" | |
Write-Output $Hashcode |
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
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs -Wait } |
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 -Version 3 | |
#Credential file path | |
$script:CredentialsFile = Join-Path $env:TEMP "SavedCredentials\Credentials.xml" | |
function Set-SavedCredential() | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory)] |
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 Test-WinCredential { | |
<# | |
.SYNOPSIS | |
Validates Windows user credentials. | |
.DESCRIPTION | |
Validates a [pscredential] instance representing user-account credentials | |
against the current user's logon domain or local machine. | |
.PARAMETER Credential |