full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Compare 2 foldertrees.ps1
Compare 2 foldertrees.ps1
function Compare-Foldertrees { param( $path1, $path2 ) $len1 = $path1.length $len2 = $path2.length . Require-function Get-MD5 Write-Host "====== First path only =======`n" gci $path1 -rec | ? {! $_.PSISContainer} | % { $fileName1 = $_.fullN...
PowerShellCorpus/PoshCode/powershell ise config.ps1
powershell ise config.ps1
<configuration> <startup> <supportedRuntime version="v4.0" /> <supportedRuntime version="v2.0.50727" /> <process> <rollForward enabled="false" /> </process> </startup> <runtime> <loadFromRemoteSources enabled="true"/> </runtime> </configuration>
PowerShellCorpus/PoshCode/Test-ADCredentials.ps1
Test-ADCredentials.ps1
Function Test-ADCredentials { Param($username, $password, $domain) Add-Type -AssemblyName System.DirectoryServices.AccountManagement $ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain $pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($ct, $domain) New-Object PSOb...
PowerShellCorpus/PoshCode/Get Active Sync devices .ps1
Get Active Sync devices .ps1
<# .SYNOPSIS Get-InactiveActiveSyncDevices pulls all user mailboxes with an Active Sync partnership and then selects the Active Sync devices that haven't synced in the specified period. These devices are sorted in ascending order and placed in a HTML table which is emailed to the specified user using a specified repl...
PowerShellCorpus/PoshCode/vCenterRetentionPolicy.ps1
vCenterRetentionPolicy.ps1
function Get-vCenterRetentionPolicy { $settings = get-view -id OptionManager-VpxSettings if ($settings) { $maxAge = ($settings.Setting | where { $_.Key -eq "task.maxAge" }).Value $maxAgeEnabled = ($settings.Setting | where { $_.Key -eq "task.maxAgeEnabled" }).Value $obj = New-Object -TypeName PSObject ...
PowerShellCorpus/PoshCode/Out-DataTable_4.ps1
Out-DataTable_4.ps1
####################### function Get-Type { param($type) $types = @( 'System.Boolean', 'System.Byte[]', 'System.Byte', 'System.Char', 'System.Datetime', 'System.Decimal', 'System.Double', 'System.Guid', 'System.Int16', 'System.Int32', 'System.Int64', 'System.Single', 'System.UInt16', 'System.UIn...
PowerShellCorpus/PoshCode/Deploy Multiple VMs v1.ps1
Deploy Multiple VMs v1.ps1
############################################################# # Deploy-VM.ps1 v1.1 # David Summers 2011/8/2 # Script to deploy VM(s) from Template(s) and set appropriate # IP config for Windows VMs. Also sets # of CPUs, MemoryMB, # port group, and several custom attributes. # Moves deployed VM to specific VMs/Te...
PowerShellCorpus/PoshCode/Access Jira (REST).ps1
Access Jira (REST).ps1
param($Issue, $Credentials = $(Get-Credential), $BaseURI = "https://your.jira.server/jira") function ConvertTo-UnsecureString( [System.Security.SecureString][parameter(mandatory=$true)]$SecurePassword) { $unmanagedString = [System.IntPtr]::Zero; try { $unmanagedString = [Runtime.Interop...
PowerShellCorpus/PoshCode/Get-Parameter 2.0.ps1
Get-Parameter 2.0.ps1
#Requires -version 2.0 #.Synopsys # Enumerates the parameters of one or more commands #.Notes # With many thanks to Hal Rottenberg, Oisin Grehan and Shay Levy # Version 0.* - By Hal Rottenberg http://poshcode.org/549 # Version 0.* - By Oisín Grehan http://poshcode.org/446 # - Added resolving ali...
PowerShellCorpus/PoshCode/Set-Clipboard.ps1
Set-Clipboard.ps1
#############################################################################\n##\n## Set-Clipboard\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\nSends the g...
PowerShellCorpus/PoshCode/Check latest BIOS Rev.ps1
Check latest BIOS Rev.ps1
$BiosRev = Get-WmiObject -Class Win32_BIOS -ComputerName $ComputerName -Credential $Credentials # Shortened URL for the Dell Support page, fileid=441102, appears to be the identifier for BIOS downloads # I tested this on a few different models of Dell workstations. $DellBIOSPage = "http://support.dell.com/suppor...
PowerShellCorpus/PoshCode/VerifyCategoryRule_1.ps1
VerifyCategoryRule_1.ps1
## From Windows PowerShell Cookbook (O'Reilly) ## by Lee Holmes (http://www.leeholmes.com/guide) Set-StrictMode -Version Latest if($message.Body -match "book") { [Console]::WriteLine("This is a message about the book.") } else { [Console]::WriteLine("This is an unknown message.") }
PowerShellCorpus/PoshCode/SqlProxy_8.psm1.ps1
SqlProxy_8.psm1.ps1
# --------------------------------------------------------------------------- ### <Author> ### Chad Miller ### </Author> ### <Description> ### Based on functions in SQLPSX. SqlProxy.psm1 module is used for administering ### SQL Server logins, users, and roles. Designed to be used with PS Remoting. ### All actio...
PowerShellCorpus/PoshCode/Get-BogonList_2.ps1
Get-BogonList_2.ps1
function Get-BogonList { <# .SYNOPSIS Gets the bogon list. .DESCRIPTION The Get-BogonList function retrieves the bogon prefix list maintained by Team Cymru. A bogon prefix is a route that should never appear in the Internet routing table. A packet routed over the public Internet (not including over ...
PowerShellCorpus/PoshCode/NetBackup Backup Report.ps1
NetBackup Backup Report.ps1
################################################################################################### # # NAME: NBU-BackupReport.ps1 # # AUTHOR: Martijn Jonker # # COMMENT: Script to create a backup report from Netbackup jobs on windows platform. # Adjust variables below this section. # The script generates a rep...
PowerShellCorpus/PoshCode/Get-ADSite-byIP.ps1
Get-ADSite-byIP.ps1
#get-site-byIP, ipv4 #written by Nathan Linley # http://myitpath.blogspot.com Param( [Parameter(Mandatory=$true,HelpMessage="IP Address")][validatepattern('^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$')]$ip, [Parameter(Mandatory=$false,HelpMessage="Netmask")]$nmask, [Parameter(Mandatory=$false,HelpMessa...
PowerShellCorpus/PoshCode/Monitor ESX with WS-MAN.ps1
Monitor ESX with WS-MAN.ps1
# WS-MAN monitoring of ESX with PowerShell. # This requires PowerShell v2 CTP3 and requires the new WS-MAN CTP # from MS (currently 64 bit only) # You will also need to allow basic auth. # (run winrm set winrm/config/client/auth @{Basic="true"} from command prompt) function Get-VMHostWSManInstance { param ( [P...
PowerShellCorpus/PoshCode/find-localadmins.ps1
find-localadmins.ps1
<# .SYNOPSIS List users in specified local group .DESCRIPTION Created: March 17, 2011 Jeff Patton This script searches ActiveDirectory for computers. It then queries each computer for the list of users who are in the local Administrators group. .PARAMETER ADSPath The LDAP URI of the container you ...
PowerShellCorpus/PoshCode/ConvertTo-JaggedObjects.ps1
ConvertTo-JaggedObjects.ps1
function ConvertTo-JaggedObjects { ################################################################################################### # .Synopsis # Convert a hashtable full of arrays into formattable objects # .Description # When you have multiple arrays that you need to somehow group together for output, C...
PowerShellCorpus/PoshCode/SearchZIP_1.psm1 .ps1
SearchZIP_1.psm1 .ps1
function SearchZIPfiles { <# .SYNOPSIS Search for (filename) strings inside compressed ZIP or RAR files (V2.2). .DESCRIPTION In any directory containing a large number of ZIP/RAR compressed Web Page files this procedure will search each individual file name for simple text strings, listing both the source RAR...
PowerShellCorpus/PoshCode/Set-IISLogLocation.ps1
Set-IISLogLocation.ps1
Function Set-IISLogLocation { <# .SYNOPSIS This command will allow you to set the IIS log location on a server or multiple servers. .DESCRIPTION This command will allow you to set the IIS log location on a server or multiple servers. .PARAMETER computer Name of computer to set log location on...
PowerShellCorpus/PoshCode/Parse nmap XML output.ps1
Parse nmap XML output.ps1
#################################################################################### # Script: parse-nmap.ps1 # Purpose: Parse the XML output file of the nmap port scanner and emit custom # objects with properties containing data from XML file. # Example: dir *.xml | .\\parse-nmap.ps1 # Author: Jason ...
PowerShellCorpus/PoshCode/Compare Table & DataRow.ps1
Compare Table & DataRow.ps1
function Compare-DataRow { param( $a, $b) # @bernd_k http://pauerschell.blogspot.com/ $diff = '' $a_columncount = $a.Table.columns.count $b_columncount = $b.Table.columns.count if ( $a_columncount -ne $b_columncount) { Write-host "Tables have different num...
PowerShellCorpus/PoshCode/Get-ExchangeDBSizes_1.ps1
Get-ExchangeDBSizes_1.ps1
<# .SYNOPSIS Get-ExchangeDBSizes - Gather data on Exchange 2007 / 2010 Mailbox Databases. .DESCRIPTION Gathers data from Exchange mailbox servers. These data include: Server\\StorageGroup\\Database (2007) or Database (2010), Total Size (in GB) of the disk, Size of the .edb file (in GB), ...
PowerShellCorpus/PoshCode/Search-Twitter.ps1
Search-Twitter.ps1
##############################################################################\n##\n## Search-Twitter\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\nSearch Tw...
PowerShellCorpus/PoshCode/PoSh Email Tester GUI.ps1
PoSh Email Tester GUI.ps1
<# .NOTES Name : PoSh Email Tester GUI Author : Bryan Jaudon <bryan.jaudon@gmail.com> Version : 1.0 Date : 10/30/2012 .Description GUI Email tester program utilizing PowerShell Send-MailMessage cmdlet. #> #requires -version 2 #region IconExtrator TypeDef $code...
PowerShellCorpus/PoshCode/PowerShell Template_2.ps1
PowerShell Template_2.ps1
Function New-Script { $strName = $env:username $date = get-date -format d $name = Read-Host "Filename" if ($name -eq "") { $name="NewTemplate" } $email = Read-Host "eMail Address" if ($email -eq "") { $email="genemagerr@hotmail.com" } $comment=@(); while($s = (Read-Host "Comment").Trim()){$comment+="$s`r`n#"} ...
PowerShellCorpus/PoshCode/Scan VB6 Code.ps1
Scan VB6 Code.ps1
#requires -version 2 # some PowerShell Functions to scan VB 6 Projects for patterns # e.g. some SQL calls # by Bernd Kriszio http://pauerschell.blogspot.com/ function Get-VBProject ($file) { # this is developed for use with Visual Basic 6 # to extract the files the contain VB Code pushd (Spli...
PowerShellCorpus/PoshCode/Help Differ 10000 v_2.01.ps1
Help Differ 10000 v_2.01.ps1
# These functions are meant to help generate a table that shows differences between # cmdlets among different versions of a module. # You will need a MoinMoin wiki to render the output. # If you don't have a MoinMoin wiki you might be able to use the sandbox at http://moinmo.in/WikiSandBox # Extracts some data fr...
PowerShellCorpus/PoshCode/Format-PoshTable.ps1
Format-PoshTable.ps1
function Format-PoshTable { #.Synopsis # Format-PoshTable puts the output in a WPF DataGrid (inline in PoshConsole) #.Description # Outputs a WPF datagrid of the objects (and properties) specified. # This grid can be sorted, rearranged, etc [CmdletBinding()] param( [parameter(ValueFromPipeline=$tru...
PowerShellCorpus/PoshCode/824c3a01-0fdd-4a67-90af-bd398fb95b05.ps1
824c3a01-0fdd-4a67-90af-bd398fb95b05.ps1
# Description: Create Events in Application log # Date: 03-05-2007 # Author: Stefan Stranger & Ken # Explanation: If you only wish to write to the event log you must do two things. The first is to create or specify a Source. # The second is to call the WriteEntry method. The source would be your applicatio...
PowerShellCorpus/PoshCode/Out-DataTable_2.ps1
Out-DataTable_2.ps1
####################### <# .SYNOPSIS Creates a DataTable for an object .DESCRIPTION Creates a DataTable based on an objects properties. .INPUTS Object Any object can be piped to Out-DataTable .OUTPUTS System.Data.DataTable .EXAMPLE $dt = Get-Alias | Out-DataTable This example creates a DataTable fro...
PowerShellCorpus/PoshCode/powershell ise config_3.ps1
powershell ise config_3.ps1
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> <runtime> <loadFromRemoteSources enabled="true"/> </runtime> </configuration>
PowerShellCorpus/PoshCode/PowerChart 0.52.ps1
PowerChart 0.52.ps1
function New-PowerChart() { #.Synopsis # Create a chart using the WPF DataVisualization Toolkit (WPFToolkit) #.Example # New-PowerChart Area { ls | ? {!$_.PSIsContainer} } -IndependentValue Name -DependentValue Length -Show #.Example # New-PowerChart Pie { ps | sort WS -desc | select -first 10 } Name WS -Sh...
PowerShellCorpus/PoshCode/Select-Xml 2.1.ps1
Select-Xml 2.1.ps1
#requires -version 2.0 # Select-Xml 2.1 and Remove-XmlNamespace function Select-Xml { #.Synopsis # This improved version of the Select-XML cmdlet lets you use XPath queries to search for text in XML strings and documents. Enter an XPath query, and use the Content, Path, or Xml parameter to specify the XML to be ...
PowerShellCorpus/PoshCode/vmrc remote connector.ps1
vmrc remote connector.ps1
#region Global var $script:viserver = "esx.local" $script:vmrc = "C:\\Program Files\\VMwareVMRC\\vmware-vmrc.exe" $script:vm = "" $script:vmt = "" $script:vmcon = "" $script:selectvm = "" $script:multiple = $FALSE #Set to TRUE for multiple VMRC Instances #endregion $vmcon = Connect-VIServer -Server $script:v...
PowerShellCorpus/PoshCode/4a37ac19-31f0-4d25-80a3-98a05980e63e.ps1
4a37ac19-31f0-4d25-80a3-98a05980e63e.ps1
#requires -version 2.0\nAdd-Type @"\npublic class Shift {\n public static int Right(int x, int count) { return x >> count; }\n public static uint Right(uint x, int count) { return x >> count; }\n public static long Right(long x, int count) { return x >> count; }\n public static ulong Right(ulong x, int ...
PowerShellCorpus/PoshCode/Get-FileEncoding_6.ps1
Get-FileEncoding_6.ps1
<# .SYNOPSIS Gets file encoding. .DESCRIPTION The Get-FileEncoding function determines encoding by looking at Byte Order Mark (BOM). Based on port of C# code from http://www.west-wind.com/Weblog/posts/197245.aspx .EXAMPLE Get-ChildItem *.ps1 | select FullName, @{n='Encoding';e={Get-FileEncoding $_.FullName}} | ...
PowerShellCorpus/PoshCode/Add Voice to Powershell_1.ps1
Add Voice to Powershell_1.ps1
### # Description: Add Voice to Powershell # Version: 1.1 (11 Nov 2008) # Mike Hays / www.mike-hays.net / blog.mike-hays.net # Virtualization, Powershell, and more... ### # This is the actual speaking part. I cheat by adding spaces # (This makes the word sound right). $spokenText = "Super ca li fragilistic e...
PowerShellCorpus/PoshCode/Test-Port_7.ps1
Test-Port_7.ps1
Param([string]$srv,$port=135,$timeout=3000,[switch]$verbose) # Test-Port.ps1 # Does a TCP connection on specified port (135 by default) $ErrorActionPreference = "SilentlyContinue" # Create TCP Client $tcpclient = new-Object system.Net.Sockets.TcpClient # Tell TCP Client to connect to machine on Port ...
PowerShellCorpus/PoshCode/LetterDiamondOneliner v2.ps1
LetterDiamondOneliner v2.ps1
&{param([char]$c)[int]$s=65;$p=$c-$s;$r=,(' '*$p+[char]$s);$r+=@(do{"{0,$p} {1}{0}"-f([char]++$s),(' '*$f++)}until(!--$p));$r;$r[-2..-99]}Z
PowerShellCorpus/PoshCode/FindNewVirtualMachines.ps1
FindNewVirtualMachines.ps1
#requires -pssnapin VMware.Vimautomation.Core Param( [int] $LastDays ) Process { $EventFilterSpecByTime = New-Object VMware.Vim.EventFilterSpecByTime If ($LastDays) { $EventFilterSpecByTime.BeginTime = (get-date).AddDays(-$($LastDays)) } $EventFilterSpec = New-Object VMwa...
PowerShellCorpus/PoshCode/New-TiedVariable.ps1
New-TiedVariable.ps1
function New-TiedVariable { #.Synopsis # Creates a ReadOnly variable that recalculates it's value each time it's read #.Description # Create a variable tied to a scriptblock by using a breakpoint ;-) #.Notes # New-TiedVariable uses breakpoints to trigger the automatic recalculation of the variables, so the ...
PowerShellCorpus/PoshCode/Unlock & Password Reset_1.ps1
Unlock & Password Reset_1.ps1
<# Author: Matt Schmitt Date: 12/4/12 Version: 2.0 From: USA Email: ithink2020@gmail.com Website: http://about.me/schmittmatt Twitter: @MatthewASchmitt Description A script checking for Locked Account, checking where a user is locked out, unlocking the user's account a...
PowerShellCorpus/PoshCode/hex2dec_4.ps1
hex2dec_4.ps1
@echo off ::interactive mode if "%1" equ "" ( if not defined run goto:interactive goto:error ) ::null results for %%i in ("0" "x0" "0x0") do if "%1" equ "%%~i" goto:null ::parsing argument(s) setlocal enabledelayedexpansion ::checking number of arguments set "arg=0" for %%i...
PowerShellCorpus/PoshCode/TabExpansion_11.ps1
TabExpansion_11.ps1
## Tab-Completion ################# ## For V2CTP3. ## This won't work on V1 and V2CTP and V2CTP2. ## 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...
PowerShellCorpus/PoshCode/New-ODataServiceProxy_1.ps1
New-ODataServiceProxy_1.ps1
function New-ODataServiceProxy { #.Synopsis # Creates a proxy class for an odata web service # YOU NEED TO BE VERY CAREFUL NOT TO OUTPUT THE PROXY OBJECT TO THE POWERSHELL HOST! #.Description # Uses the data service client utility (DataSvcUtil.exe) to generate a proxy class (and types for all objects) for an O...
PowerShellCorpus/PoshCode/Get Twitter RSS Feed_6.ps1
Get Twitter RSS Feed_6.ps1
param ([String] $ScreenName) $client = New-Object System.Net.WebClient $idUrl = "https://api.twitter.com/1/users/show.json?screen_name=$ScreenName" $data = $client.DownloadString($idUrl) $start = 0 $findStr = '"id":' do { $start = $data.IndexOf($findStr, $start + 1) if ($start -gt 0) { $s...
PowerShellCorpus/PoshCode/h20 -Hashtables 2 object_3.ps1
h20 -Hashtables 2 object_3.ps1
#hashtable to object function. #used to be able to make custom objects with math inside the pipeline #examples # 1..10 | h20 { @{karl = $_;dude = $_+1} } #modify the incoming data with an expression # gps | h20 { @{name = $_.processname; mem = $_.workingset / 1MB} } #easily flatten data with subexpressions...
PowerShellCorpus/PoshCode/Get-ADMapObject.ps1
Get-ADMapObject.ps1
# Author: Steven Murawski http://www.mindofroot.com # This script requires the Show-NetMap script from Doug Finke and the NetMap files # These can be found at http://dougfinke.com/blog/?p=465 # # Also required are the Quest AD Cmdlets. #requires -pssnapin Quest.ActiveRoles.ADManagement function Write-Help...
PowerShellCorpus/PoshCode/Get-ImageMetaData.ps1
Get-ImageMetaData.ps1
## Get-ImageMetaData -- pull EXIF, XMP, and other data from images using the BitmapMetaData ## Usage: ls *.jpg | Get-ImageMetaData | ft Length, LastWriteTime, Name, "36867" ## Note that '36867' is the decimal value of (0x9003) the EXIF tag for DateTimeOriginal ## For more information see: http://owl.phy.queen...
PowerShellCorpus/PoshCode/Object ProxyAddress Scan.ps1
Object ProxyAddress Scan.ps1
Param ( [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, HelpMessage="Enter SMTP address to search for in Active-Directory." )] [string]$objSMTP ) Function Get-ProxyAddresses ([string]$Address){ $objAD = $null $objAD = Get-QADObject -LdapFilter "(proxyAddre...
PowerShellCorpus/PoshCode/RDC RemoteApp PassMan.ps1
RDC RemoteApp PassMan.ps1
################################################## # ENV Setup ################################################## #------------------------------------------------- # Initialize-ENV #------------------------------------------------- # Usage: Used to build the execution ENV. # **Function is not for interactive ex...
PowerShellCorpus/PoshCode/set-localpwd_1.ps1
set-localpwd_1.ps1
# Sets local account passwords on one or more computers # usage [computerName1,computerName2,... | ] ./set-localpwd.ps1 [-user] <userName> [-password] <password> [[-computers] computerName1,computerName2,...] param( [string] $User , [string] $Password , [string[]] $ComputerNames = @() ) $ComputerNames ...
PowerShellCorpus/PoshCode/Test-WebDAV_1.ps1
Test-WebDAV_1.ps1
function Test-WebDav () { param ( $Url = "$( throw 'URL parameter is required.')" ) $xhttp = New-Object -ComObject msxml2.xmlhttp $xhttp.open("OPTIONS", $url, $false) $xhttp.send() if ( $xhttp.getResponseHeader("DAV") ) { $true } else { $false } }
PowerShellCorpus/PoshCode/Find Local Group Members_3.ps1
Find Local Group Members_3.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" $error.clear(...
PowerShellCorpus/PoshCode/Get-WebVideoFile.ps1
Get-WebVideoFile.ps1
<# .SYNOPSIS Download video-files from the specified RSS-feed URL, based on HTML scraping and a regular expression. .DESCRIPTION Download video-files from the specified RSS-feed URL, based on HTML scraping and a regular expression for finding the download URL. Joel Bennett`s Get-WebFile function from poshcode.or...
PowerShellCorpus/PoshCode/SetDefaultPrinter_2.ps1
SetDefaultPrinter_2.ps1
<# .SYNOPSIS Sets the Default Printer for any user on any machine in active directory. .DESCRIPTION Search AD for Computername; Select User Account and Printer and make that printer the default printer for that user on that computer. .PARAMETER Hostnme This parameter is required and should reflect the ...
PowerShellCorpus/PoshCode/get-windowsproductkey.ps1
get-windowsproductkey.ps1
function get-windowsproductkey([string]$computer) { $Reg = [WMIClass] ("\\\\" + $computer + "\\root\\default:StdRegProv") $values = [byte[]]($reg.getbinaryvalue(2147483650,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion","DigitalProductId").uvalue) $lookup = [char[]]("B","C","D","F","G","H","J","K","M","P","Q","R"...
PowerShellCorpus/PoshCode/Roman Numeral Clock.ps1
Roman Numeral Clock.ps1
function RomanNumeral($Num,$Pos) { [array]$RomanFormat="9","0","00","000","01","1","10","100","1000","02" [array]$RomanColumns="I","V","X","X","L","C" $Format=$RomanFormat[$num] $NumberOfCharacters=$Format.Length If ( $Format -ne "9" ) { For ($Counter=0;$Counter -lt ($numberOfCharacters);$count...
PowerShellCorpus/PoshCode/TabExpansion_6.ps1
TabExpansion_6.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-PipelineObject.ps1 in a same diretory. (from http://poshcode.org/author/foo...
PowerShellCorpus/PoshCode/Invoke-ElevatedCommand.ps1
Invoke-ElevatedCommand.ps1
Function Invoke-ElevatedCommand { <# .DESCRIPTION Invokes the provided script block in a new elevated (Administrator) powershell process, while retaining access to the pipeline (pipe in and out). Please note, "Write-Host" output will be LOST - only the object pipeline and errors are handled. In genera...
PowerShellCorpus/PoshCode/chkhash_23.ps1
chkhash_23.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/PowerShell Talk Chickens_2.ps1
PowerShell Talk Chickens_2.ps1
#The PowerShell Talk #Virtualization Congress 2009 # #The Chicken Counter Script #Get our cretendials #More on credential stores: http://professionalvmware.com/2009/04/09/posh-article-of-the-week-secure-credential-storage/ $credentials = Get-VICredentialStoreItem -File "c:\\scripts\\really_secure_file.xml" ...
PowerShellCorpus/PoshCode/Claimtypes, ADFS SP2010.ps1
Claimtypes, ADFS SP2010.ps1
Add-PSSnapin -Name Microsoft.SharePoint.PowerShell $claim = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IncomingClaimTypeDisplayName "EmailAddress" -SameAsIncoming $claim2 = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.microsoft.com/...
PowerShellCorpus/PoshCode/Tac (reverse cat)_1.ps1
Tac (reverse cat)_1.ps1
# From "Unix like command for tac?" thread on posh NG # solution by Keith Hill param([string]$path) $fs = New-Object System.IO.FileStream ((Resolve-Path $path), 'Open', 'Read') trap { $fs.Close(); break } $pos = $fs.Length $sb = New-Object System.Text.StringBuilder while (--$pos -ge 0) { [void]$fs.See...
PowerShellCorpus/PoshCode/ScriptSVN.ps1
ScriptSVN.ps1
# # Script from SVN Utility # ~~~~~~~~~~~~~~~~~~~~~~~ # This script processes template files and produces and output file. # Its a simple macro processor really. # We use it to extract the latest version of our database procedurrads and functions # from our source code control server to create deployment scripts....
PowerShellCorpus/PoshCode/8b29c3c3-9f8f-4a19-83de-cdc6f2129025.ps1
8b29c3c3-9f8f-4a19-83de-cdc6f2129025.ps1
#========================================================================== # NAME: getunknownsids.ps1 # # AUTHOR: Stephen Wheet # Version: 4.0 # Date: 6/11/10 # # COMMENT: # This script was created to find unknown SIDs or old domain permissions # on folders. It ignores folders where inheirtance is turned ...
PowerShellCorpus/PoshCode/Search Files by Date_1.ps1
Search Files by Date_1.ps1
<# Author: Matt Schmitt Date: 11/30/12 Version: 1.0 From: USA Email: ithink2020@gmail.com Website: http://about.me/schmittmatt Twitter: @MatthewASchmitt Description A script for finding files in a directory by Last Accessed Date. #> Write-Host "Enter Root Direc...
PowerShellCorpus/PoshCode/Wrapper 1 Select-String .ps1
Wrapper 1 Select-String .ps1
[CmdletBinding()] param( [Parameter(ParameterSetName='Object', Mandatory=$true, ValueFromPipeline=$true)] [AllowEmptyString()] [AllowNull()] [System.Management.Automation.PSObject] ${InputObject}, [Parameter(Mandatory=$true, Position=0)] [System.String[]] ${Pattern}, [P...
PowerShellCorpus/PoshCode/ConvertFrom-Property.ps1
ConvertFrom-Property.ps1
<# .SYNOPSIS Converts data from flat or single-level property files into PSObjects .DESCRIPTION Converts delimited string data into objects .PARAMETER PropertyText The text to be parsed .PARAMETER Separator The value separator string used between name=value pairs. Allows regular expressions. Def...
PowerShellCorpus/PoshCode/TabExpansion_13.ps1
TabExpansion_13.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/Get-PSVersion.ps1
Get-PSVersion.ps1
Set-Alias Ver Get-PSVersion function Get-PSVersion { [string]$Major = ($PSVersionTable).PSVersion.Major [string]$Minor = ($PSVersionTable).PSVersion.Minor [string]$Out = $Major + '.' + $Minor Write-Output $Out }
PowerShellCorpus/PoshCode/Kill-Process.ps1
Kill-Process.ps1
function Kill-Process() { param( [string[]]$ComputerNames, [string[]]$ProcessNames, $User ) ########################################################################################################### if ($ProcessNames -eq $null) {Write-Error 'The parametre "ProcessNames" cannot be empty';break} ################...
PowerShellCorpus/PoshCode/Invoke-CmdScript.ps1
Invoke-CmdScript.ps1
##############################################################################\n##\n## Invoke-CmdScript\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\nInvoke ...
PowerShellCorpus/PoshCode/Get-Hostname_3.ps1
Get-Hostname_3.ps1
# .SYNOPSIS # Print the hostname of the system. # .DESCRIPTION # This function prints the hostname of the system. You can additionally output the DNS # domain or the FQDN by using the parameters as described below. # .PARAMETER Short # (Default) Print only the computername, i.e. the same value as returned by $env...
PowerShellCorpus/PoshCode/POC-adding custom PS job.ps1
POC-adding custom PS job.ps1
#this is just a quite proof of concept, totally useless in of itself, with functions not fleshed out function get-jobrepository { [CmdletBinding()] param() $pscmdlet.JobRepository } function add-job { [CmdletBinding()] param($job) $pscmdlet.JobRepository.add($job) } $src = @" using System; using Sy...
PowerShellCorpus/PoshCode/Demo-Confirm.ps1
Demo-Confirm.ps1
### NOTE: the <#PS ... #> is the prompt! <#PS [40] #> $ConfirmPreference High <#PS [41] #> function get-confirmed { [CmdletBinding(SupportsShouldProcess=$true)]param() $ConfirmPreference } <#PS [42] #> get-confirmed High <#PS [43] #> get-confirmed -confirm Low <#PS [44] #> get-confirmed -confi...
PowerShellCorpus/PoshCode/Get-PerformanceHistory _2.ps1
Get-PerformanceHistory _2.ps1
##requires -version 2.0 ## Get-PerformanceHistory.ps1 ############################################################################################################## ## Lets you see the amount of time recent commands in your history have taken ## History: ## v2.53 - added back the Lines, Words, and Characters .... ...
PowerShellCorpus/PoshCode/ListCmdletParameters.ps1
ListCmdletParameters.ps1
# To use # Save script as LISTPARAMETERS.PS1 # # To get the parameters from a Powershell cmdlet just execute # # ./LISTPARAMETERS.PS1 -helpdata (GET-HELP GET-CHILDITEM) # # To list in a clean column, all of the parameters for GET-CHILDITEM # # ./LISTPARAMETERS.PS1 -helpdata (GET-HELP SET-QADUSER) # # To li...
PowerShellCorpus/PoshCode/new get-childitem.ps1
new get-childitem.ps1
Function Get-ChildItem { <# .ForwardHelpTargetName Get-ChildItem .ForwardHelpCategory Cmdlet #> [CmdletBinding(DefaultParameterSetName='Items', SupportsTransactions=$true)] param( [Parameter(ParameterSetName='Items', Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Sys...
PowerShellCorpus/PoshCode/Replace-InTextFile.ps1
Replace-InTextFile.ps1
# Replace-InTextFile.ps1 # Replace Strings in files param ( [string] $Path = "." , [string] $Filter # Select no files, by default.... , [string] $pattern = $(Read-Host "Please enter a pattern to match") , [string] $replace = $(Read-Host "Please enter a replacement string") ...
PowerShellCorpus/PoshCode/Findup_18.ps1
Findup_18.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; using System.Text.RegularExpressions; namespace Findup { public class FileLengthComparer : I...
PowerShellCorpus/PoshCode/OpsMgr State Changes.ps1
OpsMgr State Changes.ps1
# Description: State Changes for specified OpsMgr Monitor # Date: 09-12-2009 # Author: Stefan Stranger # Explanation: If you want to know the State Changes for a specific Monitor you can run the next PowerShell script # You need to have db permissions to the OperationsManagerdw databa...
PowerShellCorpus/PoshCode/Add-NetworkPrinter.ps1
Add-NetworkPrinter.ps1
###########################################################################" # # NAME: Add-NetworkPrinter.ps1 # # AUTHOR: Jan Egil Ring # EMAIL: jan.egil.ring@powershell.no # # COMMENT: Windows PowerShell script to map a network printer based on Active Directory group membership. # The get-GroupMembers...
PowerShellCorpus/PoshCode/Remove-FTPFile_1.ps1
Remove-FTPFile_1.ps1
function Remove-FTPFile ($Source,$UserName,$Password) { #Create FTP Web Request Object to handle connnection to the FTP Server $ftprequest = [System.Net.FtpWebRequest]::Create($Source) # set the request's network credentials for an authenticated connection $ftprequest.Credentials = New-Object System.N...
PowerShellCorpus/PoshCode/Add-TnsAdminEntry.ps1
Add-TnsAdminEntry.ps1
param ( [string] $Name = $(Read-Host "Provide a value for parameter 'Name'"), [string] $Protocol = 'TCP', [string] $Hostname = $(Read-Host "Provide a value for parameter 'Hostname'"), [string] $Port = '1521', [string] $Sid = $(Read-Host "Provide a value for parameter 'Sid'"), [System.IO.F...
PowerShellCorpus/PoshCode/Get-Entropy_2.ps1
Get-Entropy_2.ps1
function Get-Entropy { <# .SYNOPSIS Calculate the entropy of a byte array. Author: Matthew Graeber (@mattifestation) .PARAMETER ByteArray Specifies the byte array containing the data from which entropy will be calculated. .EXAMPLE C:\\PS> $RandArray = New-Object Byte[](10000) C...
PowerShellCorpus/PoshCode/New-Zip.ps1
New-Zip.ps1
Function New-Zip { <# .SYNOPSIS Create a Zip File from any files piped in. .DESCRIPTION Requires that you have the SharpZipLib installed, which is available from http://www.icsharpcode.net/OpenSource/SharpZipLib/ .NOTES File Name : PowerZip.psm1 Author : Christophe CREMON (uxone) - http://powershel...
PowerShellCorpus/PoshCode/rss2email.ps1
rss2email.ps1
# --------------------------------------------------------------------------- ### <Script> ### <Author> ### Chad Miller ### </Author> ### <Description> ### Checks an RSS feed and sends the feed information through email if it hasn't ### been seen before. ### </Description> ### <Usage> ### ./rss2email.ps1 'm...
PowerShellCorpus/PoshCode/New-Task.ps1
New-Task.ps1
<# .SYNOPSIS Creates a task in Outlook .DESCRIPTION Allows for the creation of tasks in Microsoft Outlook from Windows PowerShell. The majority of task options available can be configured with the function. .LINK http://www.leeholmes.com/blog/GettingThingsDoneOutlookTaskAutomationWithPowerShell.aspx .EXAMPLE C...
PowerShellCorpus/PoshCode/sudo for Powershell.ps1
sudo for Powershell.ps1
# sudo.ps1 # # Authors: Brian Marsh, mrigns, This guy: http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell # # Sources: # http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell # http://www.ainotenshi.org/%E2%80%98sudo%E2%80%99-for-powershell-sorta # # Version: ...
PowerShellCorpus/PoshCode/Get-FirewallStatus.ps1
Get-FirewallStatus.ps1
# returns true if windows firewall is enabled, false if it is disabled filter global:get-firewallstatus ([string]$computer = $env:computername) { if ($_) { $computer = $_ } $HKLM = 2147483650 $reg = get-wmiobject -list -namespace root\\default -computer $computer | where-object { $_.name -eq "StdRegProv" }...
PowerShellCorpus/PoshCode/Import-CmdEnvironment.ps1
Import-CmdEnvironment.ps1
# .SYNOPSIS # Import environment variables from cmd to PowerShell # .DESCRIPTION # Invoke the specified command (with parameters) in cmd.exe, and import any environment variable changes back to PowerShell # .EXAMPLE # Import-CmdEnvironment "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat" ...
PowerShellCorpus/PoshCode/ConvertTo-Hex_3.ps1
ConvertTo-Hex_3.ps1
# Ported from C# technique found here: http://forums.asp.net/p/1298956/2529558.aspx param ( [string]$SidString ) # Create SID .NET object using SID string provided $sid = New-Object system.Security.Principal.SecurityIdentifier $sidstring # Create a byte array of the proper length $sidBytes = New-Object byte[] ...
PowerShellCorpus/PoshCode/Install-Bginfo.ps1
Install-Bginfo.ps1
#Install and run BGInfo at startup using registry method as described here: #http://forum.sysinternals.com/bginfo-at-startup_topic2081.html #Setup #1. Download BgInfo http://technet.microsoft.com/en-us/sysinternals/bb897557 #2. Create a bginfo folder and copy bginfo.exe #3. Create a bginfo.bgi file by running bgi...
PowerShellCorpus/PoshCode/New-Script.ps1
New-Script.ps1
## New-Script function ## Creates a new script from the most recent commands in history ################################################################################################## ## Example Usage: ## New-Script ScriptName 4 ## creates a script from the most recent four commands ## New-Script...
PowerShellCorpus/PoshCode/FixInvalidVMs.ps1
FixInvalidVMs.ps1
#====================================================================================== # File Name : FixInvalidVMs.ps1 # Original Author : Kenneth C. Mazie # Description : Resets all "invald" or "inaccessible" virtual machines # : # Notes ...
PowerShellCorpus/PoshCode/Find Local Group Members_2.ps1
Find Local Group Members_2.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", $LocalGroup = "Administrators" $error.clear() $MemberNa...
PowerShellCorpus/PoshCode/Get-CalendarWeek_1.ps1
Get-CalendarWeek_1.ps1
# Get-CalendarWeek by Holger Adam # Simple function to retrieve the calendar week to a given or the current date. function Get-CalendarWeek { param( $Date ) # check date input if ($Date -eq $null) { $Date = Get-Date } # get current culture object $Culture = [System.Globalization.CultureIn...