full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Function Run-Script_4.ps1
Function Run-Script_4.ps1
################################################################################# # This function should be included in the PowerShell ISE profile.ps1 and it will # display the start and end times of any scripts started by clicking 'Run Script' # in the Add-ons Menu, or F2; additionally they will be logged to the S...
PowerShellCorpus/PoshCode/New-Struct.ps1
New-Struct.ps1
## New-Struct ## Creates a Struct class and emits it into memory ## The Struct includes a constructor which takes the parameters in order... ## ## Usage: ## # Assuming you have a csv file with no header and columns: artist,name,length ## New-Struct Song @{ ## Artist=[string]; ## Name=[string]; ...
PowerShellCorpus/PoshCode/UIAutomation Simple.ps1
UIAutomation Simple.ps1
[Reflection.Assembly]::Load("UIAutomationClient, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35") [Reflection.Assembly]::Load("UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35") function Select-Window { PARAM( [string]$Text="*", [switch]$Recurse, [Syst...
PowerShellCorpus/PoshCode/Get-BracketContent.ps1
Get-BracketContent.ps1
function global:Get-BracketContent { PARAM ( [string[]] $txtInput = $(Throw "Please provide input string(s)!") , [string] $patternString = '<.*>' , [switch] $caseSensitive = $false ) # Store the pattern in a variable we can change depending on caseSensitive option. Leave original pattern there to u...
PowerShellCorpus/PoshCode/Out-HTMLTable.ps1
Out-HTMLTable.ps1
<# .SYNOPSIS Takes input objects, and outputs a sortable HTML table .DESCRIPTION The function requires at least 2 parameters, an input object and a path where the result is to be output to. The function will output 3 files, a css file that determines the way the result is formatted, a javascript file ...
PowerShellCorpus/PoshCode/Watch-SG2011LeaderBoard.ps1
Watch-SG2011LeaderBoard.ps1
#requires -Version 2.0 <# .Synopsis Script that will produce table of leaders in a give category. .Description Just some fun with regex/ xml. :) It will grab SG 2011 Leader Board for a given category. Than parse the string, convert it into XML, create custom ...
PowerShellCorpus/PoshCode/RunAsAdmin Tool.ps1
RunAsAdmin Tool.ps1
<# DOWNLOAD THE DEPLOY PACKAGE FROM http://techjeeper.com/?page_id=112 for all the pieces to make this work. Author: Cody Dean (aka TechJeeper) Date: 3-16-2013 RunAsAdmin uses (and includes) the following tools: PowerShell Community Extensions SysInternals PsExec PSTerminalServices Make-ps1exewrapper.ps...
PowerShellCorpus/PoshCode/Send-Growl _2.0.ps1
Send-Growl _2.0.ps1
## This is the first version of a Growl module (just dot-source to use in PowerShell 1.0) ## v 1.0 supports a very simple notice, and no callbacks ## v 2.0 supports registering multiple message types ## supports callbacks ## v 2.1 redesigned to be a module used from apps, rather than it's own "PowerGrowler" a...
PowerShellCorpus/PoshCode/callias.ps1
callias.ps1
function prompt { $mapped_drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=4" | foreach {echo $_.deviceid} $local_drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=3" | foreach {echo $_.deviceid} $removable_drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=2" | foreach {ec...
PowerShellCorpus/PoshCode/chkhash_11.ps1
chkhash_11.ps1
# calculate SHA512 of file. function Get-SHA512([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.SHA512CryptoServiceProvider]; $hashAlgorithm = new-object $cryptoServiceProvider $stream = $file.Open...
PowerShellCorpus/PoshCode/Get-VMware-Guest-Invento.ps1
Get-VMware-Guest-Invento.ps1
#Requires -Version 2.0 #Requires –PsSnapIn Quest.ActiveRoles.ADManagement #Requires –PsSnapIn VMware.VimAutomation.Core <#> ========================================================================== This script was created and tested on the following: Name Version ----------------- ...
PowerShellCorpus/PoshCode/_1.ps1
_1.ps1
# Requires a connection to Exchange Server, or Exchange Management Shell $s = New-PSSession -ConfigurationName Microsoft.Exchange -Name ExchMgmt -ConnectionUri http://ex14.domain.local/PowerShell/ -Authentication Kerberos Import-PSSession $s # Get all Client Access Server properties for all mailboxes with an Activ...
PowerShellCorpus/PoshCode/TabExpansion_5.ps1
TabExpansion_5.ps1
## Tab-Completion ################# ## Please dot souce this script file. ## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list. ## Some features(relate to '$_' expansion) require the latest Get-Pipeline.ps1 in a same diretory. (from http://poshcode.org/author/foobar) ...
PowerShellCorpus/PoshCode/WhoAmI.ps1
WhoAmI.ps1
function whoami { [System.Security.Principal.WindowsIdentity]::GetCurrent().Name }
PowerShellCorpus/PoshCode/List AD Attributes_3.ps1
List AD Attributes_3.ps1
$forest = [DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() $Schema = $forest.schema $Properties = $Schema.FindAllProperties() foreach($property in $Properties) { "#################################" "Name: {0}" -f $property.Name "Link: {0}" -f $property.link "LinkID: {0}" -f $prope...
PowerShellCorpus/PoshCode/Get-NetView.ps1
Get-NetView.ps1
function Get-NetView { switch -regex (NET.EXE VIEW) { "^\\\\\\\\(?<Name>\\S+)\\s+" {$matches.Name}} }
PowerShellCorpus/PoshCode/Set-IPAddress_6.ps1
Set-IPAddress_6.ps1
function Set-IPAddress { param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"), [string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"), @@[string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"), [string]$gateway = $(read-host "Ent...
PowerShellCorpus/PoshCode/TabExpansion_10.ps1
TabExpansion_10.ps1
## Tab-Completion ################# ## Please dot souce this script file. ## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list. ## ## What this can do is: ## ## [datetime]::n<tab> ## [datetime]::now.d<tab> ## $a = New-Object "Int32[,]" 2,3; $b = "PowerShell","Pow...
PowerShellCorpus/PoshCode/check-disabledstatus.ps1
check-disabledstatus.ps1
# check-disabledstatus.ps1 # by Ken Hoover <ken.hoover@yale.edu> - Yale University ITS Windows Systems Team - Spring 2009 # # reads a text file of usernames and outputs CSV showing the status of that user - OK, DISABLED or NOTFOUND if (!($args[0])) { Write-Host "`nPlease specify a file containing usernames to c...
PowerShellCorpus/PoshCode/ConvertFrom-SDDL_1.ps1
ConvertFrom-SDDL_1.ps1
filter ConvertFrom-SDDL { <# .SYNOPSIS Convert a raw security descriptor from SDDL form to a parsed security descriptor. Author: Matthew Graeber (@mattifestation) .DESCRIPTION ConvertFrom-SDDL generates a parsed security descriptor based upon any string in raw security descriptor definition l...
PowerShellCorpus/PoshCode/SNTP.ps1
SNTP.ps1
\n<#\n.SYNOPSIS\nGets the SNTP servers a machine is configured to use\n \n.DESCRIPTION\nGets the SNTP servers a machine is configured to use\n \n.PARAMETER Server\nThe machine to get the SNTP Servers for\n \n.EXAMPLE\nPS C:\\> Get-SNTPServer -Server MachineName\nThis is return the SNTP servers for MachienName\n \n.EXAM...
PowerShellCorpus/PoshCode/Update-AdminPassword.ps1
Update-AdminPassword.ps1
<# .SYNOPSIS Local administrator password update .DESCRIPTION This script changes the local administrator password. .PARAMETER ADSPath The ActiveDirectory namespace to search for computers .PARAMETER AdminAccount The username of the administrator account .PAR...
PowerShellCorpus/PoshCode/chkhash_24.ps1
chkhash_24.ps1
# calculate SHA512 of file. function Get-SHA512([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.SHA512CryptoServiceProvider]; $hashAlgorithm = new-object $cryptoServiceProvider $stream = $file.Open...
PowerShellCorpus/PoshCode/Search-SPN.ps1
Search-SPN.ps1
<# .SYNOPSIS This function is used for finding all AD objects with a given SPN. .DESCRIPTION Finds all AD objects that have a given SPN. Wildcard search patterns are acceptable. .PARAMETER SearchRoot The root path at which to search. Should be in the form of "LDAP://xyz". .PARAMETER ...
PowerShellCorpus/PoshCode/Deploy VM with Static IP.ps1
Deploy VM with Static IP.ps1
# 1. Create a simple customizations spec: $custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows -OrgName “My Organization” -FullName “MyVM” -Domain “MyDomain” –DomainAdminUsername “user” –DomainAdminPassword “password” # 2. Modify the default network customization settings: $custSpec | Get-OSCustom...
PowerShellCorpus/PoshCode/Import-UniqueModule.ps1
Import-UniqueModule.ps1
## WARNING: I take no responsibility for how weird this is. function Import-UniqueModule { param([Parameter(Mandatory=$true)][String]$ModuleName) $unique = [guid]::NewGuid().Guid -replace "-" Import-Module $ModuleName -Prefix $unique Get-Command -Module $ModuleName | New-Alias -Name {$_.Name -replace $un...
PowerShellCorpus/PoshCode/Start-Encryption.ps1
Start-Encryption.ps1
## Start-Encryption ################################################################################################## ## Rijndael symmetric key encryption ... with no passes on the key. Very lazy. ## USAGE: ## $encrypted = Encrypt-String "Oisin Grehan is a genius" "P@ssw0rd" ## Decrypt-String $encrypted "P@ssw0rd...
PowerShellCorpus/PoshCode/Ayth.ps1
Ayth.ps1
# ======================================================================== # # Microsoft PowerShell Source File -- Created with PowerShell Plus Professional # # NAME: Disable-MassMailPF.ps1 # # AUTHOR: Darrin Henshaw , Ignition IT Canada Ltd. # DATE : 8/13/2008 # # COMMENT: Used to disable mail on an impo...
PowerShellCorpus/PoshCode/Get_Set Signature _3.0.ps1
Get_Set Signature _3.0.ps1
#Requires -version 2.0 ## Authenticode.psm1 updated for PowerShell 2.0 (with time stamping) #################################################################################################### ## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets ## These properly parse paths, so they...
PowerShellCorpus/PoshCode/vSphere Resultant Privs.ps1
vSphere Resultant Privs.ps1
# Need the Quest ActiveRoles cmdlets for this one. Add-PSSnapin Quest.ActiveRoles* -ea SilentlyContinue function Get-Groups { param($principal) # Start with this principal's base set of groups. Write-Verbose "Checking principal $principal" $groups = Get-QADUser $principal | Get-QADMemberOf # Groups ca...
PowerShellCorpus/PoshCode/Get-PipeLineObject_2.ps1
Get-PipeLineObject_2.ps1
# For TabExpansion.ps1 # this requires latest TabExpansion.ps1 in a same directory function Get-PipeLineObject { $i = -2 $property = $null do { $str = $line.Split("|") # extract the command name from the string # first split the string into statements and pipeline elements ...
PowerShellCorpus/PoshCode/VM Last Poweron Time.ps1
VM Last Poweron Time.ps1
# Get a VM's last power on date based on the VM's events. # Requires PowerCLI 4.0 and PowerShell v2. function Get-LastPowerOn { param( [Parameter( Mandatory=$true, ValueFromPipeline=$true, HelpMessage="VM" )] [VMware.VimAutomation.Types.VirtualMachin...
PowerShellCorpus/PoshCode/Poczta.ps1
Poczta.ps1
param( [switch]$Help , [string] $User , [string] $Password , [string[]] $ComputerNames = @() ) $usage = @' Get-OUComputerNames usage : [computerName1,computerName2,... | ] ./Set-LocalPassword.ps1 [-user] <userName> [-password] <password> [[-computers] computerName1,computerName2,...] returns : Sets lo...
PowerShellCorpus/PoshCode/Select-FilteredObject.ps.ps1
Select-FilteredObject.ps.ps1
##############################################################################\n##\n## Select-FilteredObject\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nPr...
PowerShellCorpus/PoshCode/Decode Psi IM passwords.ps1
Decode Psi IM passwords.ps1
function decrypt-psi ($jid, $pw) { $OFS = ""; $u = 0; for($p=0;$p -lt $pw.Length;$p+=4) { [char]([int]"0x$($pw[$p..$($p+3)])" -bxor [int]$jid[$u++]) } } $accounts = ([xml](cat ~\\psidata\\profiles\\default\\accounts.xml))["accounts"]["accounts"] foreach($account in ($accounts | gm a[0-9]*)) { ...
PowerShellCorpus/PoshCode/New-SelfRestartingTask.ps1
New-SelfRestartingTask.ps1
function New-SelfRestartingTask { #.Notes # For production use you should consider investigating more specific matching in the Query clause. # # There are many possibilities here: you could watch for instances of a process with specific command-line parameters, or a certain caption, etc. Or, you could match again...
PowerShellCorpus/PoshCode/TheMathFunction.ps1
TheMathFunction.ps1
Add-Type -Path (Join-Path (Split-Path $Profile) Libraries\\LoreSoft.MathExpressions.dll) ## You can dot-source this in 1.0 after uncommenting the following line, and deleting the first and last lines. # [Reflection.Assembly]::LoadFrom((Join-Path (Split-Path $Profile) Libraries\\LoreSoft.MathExpressions.dll)) | Out-Nu...
PowerShellCorpus/PoshCode/Home Directory Perms.ps1
Home Directory Perms.ps1
$FolderPath = "\\\\site filer\\userdata$\\" $rootfolder = Get-ChildItem -Path $FolderPath -recurse foreach ($file in $rootfolder) { $file.FullName Get-Acl $file.FullName | Format-List $acl = Get-Acl $file.FullName $acl.Access | %{$acl.RemoveAccessRule($_)} #...
PowerShellCorpus/PoshCode/Publish Friendfeed Entry.ps1
Publish Friendfeed Entry.ps1
#Publish FF Entry using PowerShell script #Description: PowerShell script to publish an entry to Friendfeed. #Change the FF Username and Remotekey in the script. #More info on the FF Api: http://friendfeed.com/api/ #Change the FF Username and Remotekey in the script. #Author: Stefan Stranger #Website: http://tiny...
PowerShellCorpus/PoshCode/Shift Operators_1.ps1
Shift Operators_1.ps1
#requires -version 2.0 Add-Type @" public class Shift { public static int Left(int x, int count) { return x >> count; } public static uint Left(uint x, int count) { return x >> count; } public static long Left(long x, int count) { return x >> count; } public static ulong Left(ulong x, int ...
PowerShellCorpus/PoshCode/LibraryMSCS.ps1
LibraryMSCS.ps1
# ------------------------------------------------------------------------ ### <Script> ### <Author> ### Chad Miller ### </Author> ### <Description> ### Defines functions for working with Microsoft Cluster Service (MSCS) ### </Description> ### <Usage> ### . ./LibraryMSCS.ps1 ### </Usage> ### </Script> # --...
PowerShellCorpus/PoshCode/Get-Software Function.ps1
Get-Software Function.ps1
Function Get-Software{ <# .SYNOPSIS Gets the software applications on a remote computer. .DESCRIPTION This function interrogates the remote registry for installed software products. It then returns an array of powershell objects that can be sorted and parsed. ...
PowerShellCorpus/PoshCode/Measure-File.ps1
Measure-File.ps1
#.Synopsis # Calculate statistics about files #.Description # A lightweight simulation of unix's "wc" word count application #.Parameter $file # Accepts PIPELINE input # The file name(s) or wildcard patterns for the file(s) you want to count #.Example # wc *.ps1 # # Calculates line, word, and character ...
PowerShellCorpus/PoshCode/Get-Desktop.ps1
Get-Desktop.ps1
Add-Type @' #region License // Desktop 1.1 // * // Copyright (C) 2004 http://www.onyeyiri.co.uk // Coded by: Nnamdi Onyeyiri // // This code may be used in any way you desire except for commercial use. // The code can be freely redistributed unmodified as long as all of the...
PowerShellCorpus/PoshCode/Get-Payment.ps1
Get-Payment.ps1
function Get-Payment { param ( $LoanAmount, [double]$InterestRatePerPeriod, $NumberPayments ) $a = $LoanAmount $b = $InterestRatePerPeriod*[math]::Pow(($InterestRatePerPeriod + 1),$NumberPayments) $c = [math]::Pow((1+$InterestRatePerPeriod),$NumberPayments) - 1 $payment = $a*($b/$c) "{0:C}" -f $payment } ...
PowerShellCorpus/PoshCode/ConvertHelpTo-Html.ps1
ConvertHelpTo-Html.ps1
## ConvertTo-DekiContent (aka Convert Help to Html) #################################################################################################### ## Converts the -Full help output to HTML markup for insertion into web pages. #####################################################################################...
PowerShellCorpus/PoshCode/Find Local Group Members_5.ps1
Find Local Group Members_5.ps1
# Author: Hal Rottenberg # Purpose: Find matching members in a local group # Used tip from RichS here: http://powershellcommunity.org/Forums/tabid/54/view/topic/postid/1528/Default.aspx # Change these two to suit your needs $ChildGroups = "Domain Admins", "Group Two" $LocalGroup = "Administrators" $MemberName...
PowerShellCorpus/PoshCode/Compare-DataSources_1.ps1
Compare-DataSources_1.ps1
#Define DPMHosts [CmdletBinding()] param([string]$PrimaryDPMHost, [string]$SecondaryDPMHost); Write-Verbose "Compare-DataSources.ps1 written by Shai Perednik shaiss@gmail.com" Write-Verbose "Primary DPM Host: $PrimaryDPMHost" Write-Verbose "Secondary DPM Host: $SecondaryDPMHost" #Load DPM Snaping Write-Verbo...
PowerShellCorpus/PoshCode/ConvertTo-CliXml_3.ps1
ConvertTo-CliXml_3.ps1
#requires -version 2.0 function ConvertTo-CliXml { param( [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)] [ValidateNotNullOrEmpty()] [PSObject[]]$InputObject ) begin { $type = [PSObject].Assembly.GetType('System.Management.Automation.Serializer') ...
PowerShellCorpus/PoshCode/Ellipsis.ps1
Ellipsis.ps1
## Usage: ls | ... FullName ################################################ ${function:...} = { process { $_.$($args[0]) } }
PowerShellCorpus/PoshCode/Get-Parameter_9.ps1
Get-Parameter_9.ps1
function Get-Parameter ( $Cmdlet, [switch]$ShowCommon, [switch]$Full ) { $command = Get-Command $Cmdlet -ea silentlycontinue # resolve aliases (an alias can point to another alias) while ($command.CommandType -eq "Alias") { $command = Get-Command ($command.definition) } if (-not $command) { return }...
PowerShellCorpus/PoshCode/VM Performance Report_2.ps1
VM Performance Report_2.ps1
<# .SYNOPSIS The script creates an HTML report for given vSphere VM's, that contains VM performance data over a given period. The script then emails the report to a given address. .DESCRIPTION The script requires an input file, supplied as an argument to the script. The first line of this file contains an e...
PowerShellCorpus/PoshCode/Add-RelativePathCapture..ps1
Add-RelativePathCapture..ps1
##############################################################################\n##\n## Add-RelativePathCapture\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\n...
PowerShellCorpus/PoshCode/Test-Hash 2.ps1
Test-Hash 2.ps1
function Test-Hash { #.Synopsis # Test the HMAC hash(es) of a file #.Description # Takes the HMAC hash of a file using specified algorithm, and optionally, compare it to a baseline hash #.Example # Get-ChildItem -File | Test-Hash -BasePath . | Format-Table -Auto # # This example shows how to list th...
PowerShellCorpus/PoshCode/Get-ObservedIPRange_1.ps1
Get-ObservedIPRange_1.ps1
function Get-ObservedIPRange { param( [Parameter(Mandatory=$true,ValueFromPipeline=$true,HelpMessage="Physical NIC from Get-VMHostNetworkAdapter")] [VMware.VimAutomation.Client20.Host.NIC.PhysicalNicImpl] $Nic ) process { $hostView = Get-VMHost -Id $Nic.VMHostId | Get-View -Property ConfigManager ...
PowerShellCorpus/PoshCode/Get-LockoutInfo.ps1
Get-LockoutInfo.ps1
<###################################################### # Find Lockout Events # # # # Pre-Requisites: Domain Admin Rights, Writeable # # C:\\temp directory on both the local machine and # # the domain controllers. ...
PowerShellCorpus/PoshCode/h20 -Hashtables 2 object_4.ps1
h20 -Hashtables 2 object_4.ps1
uCMzpE this is delisious! xfather123
PowerShellCorpus/PoshCode/get-netstat 1.2.ps1
get-netstat 1.2.ps1
$netstat = netstat -a -n -o | where-object { $_ -match "(UDP|TCP)" } [regex]$regexTCP = '(?<Protocol>\\S+)\\s+((?<LAddress>(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?))|(?<LAddress>\\[?[0-9a-fA-f]{0,4}(\\:([0-9a-fA-f]{0,4})){1...
PowerShellCorpus/PoshCode/IPv4 Helpers.ps1
IPv4 Helpers.ps1
Function ConvertTo-BinaryIP { #.Synopsis # Convert an IP address to binary #.Example # ConvertTo-BinaryIP -IP 192.168.1.1 Param ( [string] $IP ) Process { $out = @() Foreach ($octet in $IP.split('.')) { $strout = $null 0.....
PowerShellCorpus/PoshCode/Compress-Bitmap.ps1
Compress-Bitmap.ps1
function Compress-Bitmap { PARAM( [Parameter(Mandatory=$true, ValueFromPipeline=$true)] [IO.FileInfo]$SourceFile , [Parameter(Mandatory=$true, Position=1)] [String]$DestinationFile , [Parameter(Mandatory=$false)] [Int]$Width , [Parameter(Mandatory=$false)] [Int]$Height , [Parame...
PowerShellCorpus/PoshCode/Easy Snapshot Tool.ps1
Easy Snapshot Tool.ps1
#Generated Form Function function GenerateForm { ######################################################################## # Code Generated By: Richard Yaw # Generated On: 19/04/2012 # # Easy Snapshot Tool for VMware # - GUI based tool # - Centralised view of all snapshots in a vCenter server # - Create and del...
PowerShellCorpus/PoshCode/edit-file.ps1
edit-file.ps1
function edit-file2 ([string]$path=newfile.ps1) { $paths = @(resolve-path $path -ErrorAction SilentlyContinue); if ($paths.count -gt 1) {if ($psplus.Confirm(You are about to open the below files. Are you sure?, Open multiple files, $paths) -eq $FALSE) {break} } elseif ($paths.count -eq 0) { if ($psplus.Confirm(No fi...
PowerShellCorpus/PoshCode/POC csharp expressions_3.ps1
POC csharp expressions_3.ps1
$mytypes = @() function run-csharpexpression([string] $expression ) { $global:ccounter = [int]$ccounter + 1 $local:name = [system.guid]::NewGuid().tostring().replace('-','_').insert(0,"csharpexpr") $local:ns = "ShellTools.DynamicCSharpExpression.N${ccounter}" $local:template = @" using System; using System....
PowerShellCorpus/PoshCode/PSISELibrary.ps1
PSISELibrary.ps1
Function Replace-TabsWithSpace { <# .SYNOPSIS Replaces a tab character with 4 spaces .DESCRIPTION This function examines the selected text in the PSIE SelectedText property and every tab character that is found is replaced with 4 spaces. .PARAMETER...
PowerShellCorpus/PoshCode/chkhash_10.ps1
chkhash_10.ps1
# calculate SHA512 of file. function Get-SHA512([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.SHA512CryptoServiceProvider]; $hashAlgorithm = new-object $cryptoServiceProvider $stream = $file.Open...
PowerShellCorpus/PoshCode/Export-SPListToSQL_1.ps1
Export-SPListToSQL_1.ps1
#Change these settings as needed #MS Access 2007 Data Components required $connString = 'Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=2;RetrieveIds=Yes; DATABASE=http://sharepoint.acme.com/;LIST={96801432-2d03-42b8-82b0-ac96ca9fea8a};' #See http://chadwickmiller.spaces.live.com/blog/cns!EA42395138308430!275.entry for ...
PowerShellCorpus/PoshCode/Test-UserCredential_6.ps1
Test-UserCredential_6.ps1
function Test-UserCredential { [CmdletBinding()] [OutputType([System.Boolean])] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Username, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Password, [Parameter()] [Switch] $Domain ) ...
PowerShellCorpus/PoshCode/New Portgroups.ps1
New Portgroups.ps1
get-vc virtualCenterServerName get-vmhost | Get-VirtualSwitch -Name SwitchName | New-VirtualPortGroup -Name VLAN_12 -VLANID 12
PowerShellCorpus/PoshCode/datareader to dataset.ps1
datareader to dataset.ps1
@@This code was copied from the site http://www.ti4fun.com @@----------------------------------------------------------- Public Function ConvDataReaderToDataTable(Byval command As System.Data.SqlClient.SqlCommand) As System.Data.DataTable Dim datatable As New System.Data.DataTable Dim reader As ...
PowerShellCorpus/PoshCode/TabExpansion_15.ps1
TabExpansion_15.ps1
## Tab-Completion ################# ## Please dot souce this script file. ## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list. ## ## What this can do is: ## ## [datetime]::n<tab> ## [datetime]::now.d<tab> ## $a = New-Object "Int32[,]" 2,3; $b = "PowerShell","Pow...
PowerShellCorpus/PoshCode/Select-UserGroup.ps1
Select-UserGroup.ps1
New-Grid -ControlName SelectUserGroups -Columns Auto,* -Rows 4 { $GetGroups = { $user = Get-QADUuser $this.Text -SizeLimit 1 if($User.LogonName -eq $this.Text -or $User.Email -eq $this.Text) { $this.Foreground = "Black" $Group.ItemsSource = Get-QADGroup -ContainsMember...
PowerShellCorpus/PoshCode/Email attachments_1.ps1
Email attachments_1.ps1
$file = "MYFILE.TXT" $smtpServer = "MYSMTPSERVER.EMAIL.CO.UK" $msg = new-object Net.Mail.MailMessage $att = new-object Net.Mail.Attachment($file) $smtp = new-object Net.Mail.SmtpClient($smtpServer) $msg.From = "FROMME@EMAIL.CO.UK" $msg.To.Add("TOME@EMAIL.CO.UK") $msg.Subject = "MY SUBJECT" $msg.Body = "MY...
PowerShellCorpus/PoshCode/New-XVM_14.ps1
New-XVM_14.ps1
#EXAMPLES <# New-XVM -ComputerName HYPERVSVR02 -Name "WS2012-TESTSVR01" -SwitchName "External(192.168.1.0/24)" -VhdType NoVHD New-XVM -ComputerName HYPERVSVR02 -Name "WS2012-TESTSVR02" -SwitchName "External(192.168.1.0/24)" -VhdType ExistingVHD -VhdPath D:\\vhds\\WS2012-TESTSVR02.vhdx New-XVM -ComputerName HYPERVSV...
PowerShellCorpus/PoshCode/_1.168.1.1.ps1
_1.168.1.1.ps1
function Set-IPAddress { param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"), [string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"), [string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"), [string]$gateway = $(read-host "Enter...
PowerShellCorpus/PoshCode/SyntaxHighlighter Brush_2.ps1
SyntaxHighlighter Brush_2.ps1
/** * PowerShell 2.0 Brush for highlighter 2.0 * * SyntaxHighlighter http://alexgorbatchev.com/wiki/SyntaxHighlighter * * @version * 2.1.0 (April 07 2009) * * @copyright * Copyright (C) 2008-2009 Joel Bennett http://HuddledMasses.org/ * * @license * This file is for SyntaxHighlighter. * ...
PowerShellCorpus/PoshCode/Invoke-ElevatedCommand.p.ps1
Invoke-ElevatedCommand.p.ps1
##############################################################################\n##\n## Invoke-ElevatedCommand\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nR...
PowerShellCorpus/PoshCode/Set-ADUserRandomPassword.ps1
Set-ADUserRandomPassword.ps1
###########################################################################" # # NAME: Set-ADUserRandomPassword.ps1 # # AUTHOR: Jan Egil Ring # EMAIL: jan.egil.ring@powershell.no # # COMMENT: This script are used to set a random password for Active Directory users in a specified Organizational Unit. It stores th...
PowerShellCorpus/PoshCode/VHDFunctions_1.psm1.ps1
VHDFunctions_1.psm1.ps1
<# Name: VHDFunctions.psm1 Author: Rich Kusak (rkusak@cbcag.edu) Created: 2009-10-23 LastEdit: 2009-11-03 08:57 Included Functions: Dismount-VHD Initialize-VHD Mount-VHD New-VHD Set-VHDBootConfiguration Test-VHD #> <# .SYNOPSIS Dismount a VHD file from the system. .DESCRIPTION This f...
PowerShellCorpus/PoshCode/Get-Parameter function.ps1
Get-Parameter function.ps1
function Get-Parameters { param([string]$CommandName, [switch]$IncludeCommon) try { $command = get-command $commandname $parameters = (new-object System.Management.Automation.CommandMetaData $command, $includecommon).Parameters $parameters.getenumerator() # unroll dictionary } catch ...
PowerShellCorpus/PoshCode/LibraryChart_4.ps1
LibraryChart_4.ps1
# --------------------------------------------------------------------------- ### <Script> ### <Author> ### Chad Miller ### </Author> ### <Description> ### Defines functions for wokring with Microsoft Chart Control for .NET 3.5 Framework ### Pipe output of Powershell command to Out-Chart function and specify c...
PowerShellCorpus/PoshCode/Function Run-Script.ps1
Function Run-Script.ps1
function Run-Script { if ($psISE.CurrentFile.DisplayName.StartsWith("Untitled")) { return } $script = $psISE.CurrentFile.DisplayName $psISE.CurrentFile.Save() $logfile = "$env:programfiles\\Sea Star Development\\" + "Script Monitor Service\\ScriptMon.txt" #Change t...
PowerShellCorpus/PoshCode/Get-NetworkStatistics_1.ps1
Get-NetworkStatistics_1.ps1
function Get-NetworkStatistics { [OutputType('System.Management.Automation.PSObject')] [CmdletBinding(DefaultParameterSetName='name')] param( [Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName='port')] [System.String]$Port='*', [Parameter(Position=0,ValueFromPipeline=$true,ParameterSe...
PowerShellCorpus/PoshCode/Copy-History.ps1
Copy-History.ps1
##############################################################################\n##\n## Copy-History\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nCopy select...
PowerShellCorpus/PoshCode/Send-MailMessage.ps1
Send-MailMessage.ps1
##############################################################################\n##\n## Send-MailMessage\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n## Illustrate the techniques used to send an email in PowerShell.\n## In version two, use the Send-MailMessa...
PowerShellCorpus/PoshCode/Solarized (Dark) Theme.ps1
Solarized (Dark) Theme.ps1
<?xml version="1.0" encoding="utf-16"?> <StorableColorTheme xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Keys> <string>ErrorForegroundColor</string> <string>ErrorBackgroundColor</string> <string>WarningForegroundColor</string> <string>Warni...
PowerShellCorpus/PoshCode/Split-Job.ps1
Split-Job.ps1
#requires -version 1.0 ################################################################################ ## Run commands in multiple concurrent pipelines ## by Arnoud Jansveld - www.jansveld.net/powershell ## ## Basic "drop in" usage examples: ## - Functions that accept pipelined input: ## Without Spli...
PowerShellCorpus/PoshCode/Queue Checker.ps1
Queue Checker.ps1
foreach ($ExchangServer in (Get-ExchangeServer | Where { $_.isHubTransportServer -eq $True})) {Get-queue -Server $ExchangeServer}
PowerShellCorpus/PoshCode/Script Listing.ps1
Script Listing.ps1
$pathToScripts = "C:\\Scripts\\*" foreach($itm in get-childitem $pathToScripts -include *.ps1 -recurse) {"{0,-25}{1,0}" -f ((" " + $itm.name) -replace ".ps1",""), ((get-content $itm | where {$_ -like "*Purpose:*"}) -replace "# Purpose: ","")}
PowerShellCorpus/PoshCode/Twitbrain cheat.ps1
Twitbrain cheat.ps1
#Twitbrain Cheat PowerShell script #Description: PowerShell script to beat everyone at the Twitter twitbrain game # For more info follow @twitbrain at www.twitter.com #Change the Twitter Username and Password in the script. #Author: Stefan Stranger #Website: http://tinyurl.com/sstranger #Date: 03/07/2...
PowerShellCorpus/PoshCode/Get-Sequence.ps1
Get-Sequence.ps1
## Get-Sequence ## Optionless implementation of seq for PowerShell ############################################################################ ## Most of the options don't apply because they convert the numbers to text ## which isn't something a PowerShell Seq wants to do :) ####################################...
PowerShellCorpus/PoshCode/Read-HostWithPrompt.ps1
Read-HostWithPrompt.ps1
#############################################################################\n##\n## Read-HostWithPrompt\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nRead ...
PowerShellCorpus/PoshCode/Set-Computername_3.ps1
Set-Computername_3.ps1
function Set-ComputerName { param( [switch]$help, [string]$originalPCName=$(read-host "Please specify the current name of the computer"), [string]$computerName=$(read-host "Please specify the new name of the computer")) $usage = "set-ComputerName -originalPCname CurrentName -computername AnewName" if (...
PowerShellCorpus/PoshCode/Get-NICSettings.ps1
Get-NICSettings.ps1
# Get-NICSettings by Hugo Peeters of www.peetersonline.nl ######################################################### $serverName = Read-Host "Enter server name" $NicConfig = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $serverName $myCol = @() ForEach ($Nic in $NicConfig) { If ($Nic.IPAddr...
PowerShellCorpus/PoshCode/play-note(s)_1.ps1
play-note(s)_1.ps1
function Play-Note([string]$note,[int] $duration = 5) { if (!($note -match '(\\d+)')) { $note+='4' };[void]($note -match '([A-G#]{1,2})(\\d+)') [console]::Beep((440 * [math]::Pow([math]::pow(2,(1/12)), (([int] $matches[2]) - 4)* 12 + $( switch($matches[1]) { 'A' { 0 } 'A#' { 1 } 'Bb' { 1 } '...
PowerShellCorpus/PoshCode/Password Gen Form V2.ps1
Password Gen Form V2.ps1
$rs=[RunspaceFactory]::CreateRunspace() $rs.ApartmentState = "STA" $rs.ThreadOptions = "ReuseThread" $rs.Open() $ps = [PowerShell]::Create() $ps.Runspace = $rs $ps.Runspace.SessionStateProxy.SetVariable("pwd",$pwd) [void]$ps.AddScript({ #Load Required Assemblies Add-Type –assemblyName Presentation...
PowerShellCorpus/PoshCode/VerifyCategoryRule.ps1
VerifyCategoryRule.ps1
## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n\nSet-StrictMode -Version Latest\n\nif($message.Body -match "book")\n{\n [Console]::WriteLine("This is a message about the book.")\n}\nelse\n{\n [Console]::WriteLine("This is an unknown message.")\n}
PowerShellCorpus/PoshCode/Get-CrawlHealth (MOSS)_2.ps1
Get-CrawlHealth (MOSS)_2.ps1
[reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null [reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server") | out-null [reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") | out-null @@#NOTE: I've set strict crawl freshness/crawl duration/success rati...
PowerShellCorpus/PoshCode/UIAutomation 1.9.ps1
UIAutomation 1.9.ps1
## UI Automation v 1.8 -- REQUIRES the Reflection module (current version: http://poshcode.org/3174 ) ## # WASP 2.0 is getting closer, but this is still just a preview: # -- a lot of the commands have weird names still because they're being generated ignorantly # -- eg: Invoke-Toggle.Toggle and Invoke-Invoke.Invo...
PowerShellCorpus/PoshCode/Add-SqlTable.ps1
Add-SqlTable.ps1
try {add-type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" -EA Stop} catch {add-type -AssemblyName "Microsoft.SqlServer.Smo"} ####################### function Get-SqlType { param([string]$TypeName) switch ($TypeName) { 'Bool...
PowerShellCorpus/PoshCode/Findup_12.ps1
Findup_12.ps1
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Security.Cryptography; using System.Runtime.InteropServices; using Microsoft.Win32; using System.IO; namespace Findup { public class FileInfoExt { public FileInfoExt(FileInfo fi) ...