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
#Checks the status of $ServiceName and kills it if in the 'Stop Pending' state. | |
#Creates an event log; logs results to it | |
#Get-Random (Get-Service | Select-Object -ExpandProperty Name) | Kill-HungService -Verbose | |
Function script:Kill-HungService { | |
[CmdletBinding()] | |
param( | |
[Parameter(ValueFromPipeline=$True,Mandatory=$True,HelpMessage="Service to search for")] | |
[string]$script:ServiceName | |
) |
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 script:Invoke-Credentials { | |
[CmdletBinding()] | |
param( | |
[Parameter(HelpMessage="Specify the username for the stored credential")] | |
[ValidateNotNullOrEmpty()] | |
[string]$Script_Username = "svc.username", #Username goes here | |
[Parameter(HelpMessage="Specify the path to store the credential")] | |
[ValidateNotNullOrEmpty()] | |
[string]$Script_CredFolder = "C:\Automate\", |
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
<# | |
.SYNOPSIS | |
Backup-CiscoConfig.ps1 SSHs to a Cisco device and backs up the running configuration to a TFTP server.. Utilizes the Posh-SSH module. | |
.DESCRIPTION | |
This script is not possible without darkoperator's Posh-SSH module. Thanks! | |
To do: Parameterize the device list. 10/05/16 | |
Grab the output of long commands by setting the terminal length to 0 to disable pagination. "term len 0" | |
Log commands entered on the Cisco device to ensure they're running: |
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 Convert-ToBase64 { | |
param( | |
[CmdletBinding()] | |
[Parameter(ValueFromPipeline=$True,Mandatory=$True,HelpMessage="String to encode to base64")] | |
[ValidateNotNullOrEmpty()] | |
$String | |
) | |
$StringToByteArr = [System.Text.Encoding]::UTF8.GetBytes($String) #Converts string to byte array | |
$Base64String = [System.Convert]::ToBase64String($StringToByteArr) #Converts byte array to b64 string |
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-StringHash { | |
param( | |
[CmdletBinding()] | |
[Parameter(ValueFromPipeline=$True,Mandatory=$True,HelpMessage="String to hash")] | |
$String, | |
[Parameter(HelpMessage="Hash algorithm")] | |
[ValidateSet('MD5','RIPEMD160','SHA1','SHA256','SHA384','SHA512')] | |
$Algorithm = "SHA1" | |
) | |
$StringBuilder = New-Object System.Text.StringBuilder |
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-UserGroups { | |
<# | |
.EXAMPLE | |
PS C:\> Get-UserGroups -GroupName "Domain Admins" | |
.EXAMPLE | |
PS C:\> [bool](Get-UserGroups -GroupName "Domain") | |
.EXAMPLE | |
PS C:\> Get-UserGroups -UserName elliot.alderson@e-corp-usa.com |
NewerOlder