full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Get-ADGroupModifications_1.ps1
Get-ADGroupModifications_1.ps1
###########################################################################" # # NAME: Get-ADGroupModificationsReport.ps1 # # AUTHOR: Jan Egil Ring # EMAIL: jan.egil.ring@powershell.no # # COMMENT: Generates a HTML-report of Active Directory group membership modifications (addings and deletions). # Sp...
PowerShellCorpus/PoshCode/Invoke-LocalizedScript.p.ps1
Invoke-LocalizedScript.p.ps1
Set-StrictMode -Version Latest\n\n## Create some default messages for English cultures, and\n## when culture-specific messages are not available.\n$messages = DATA {\n @{\n Greeting = "Hello, {0}"\n Goodbye = "So long."\n }\n}\n\n## Import localized messages for the current culture.\nImport-Localize...
PowerShellCorpus/PoshCode/Convert-BounceToX_3.ps1
Convert-BounceToX_3.ps1
# $Id: Convert-BounceToX500.ps1 610 2010-11-16 00:39:19Z jon $ # $Revision: 610 $ #.Synopsis # Convert Bounce to X500 #.Description # Convert URL Encoded address in a Bounce message to an X500 address # that can be added as an alias to the mail-enabled object #.Parameter bounceAddress # URL Encoded bounce...
PowerShellCorpus/PoshCode/9efa67c2-1147-4c7c-92f8-98b63b15cebd.ps1
9efa67c2-1147-4c7c-92f8-98b63b15cebd.ps1
Function Get-VMHostNetworks { <# .SYNOPSIS Return a list of networks from a given host .DESCRIPTION After connecting to your VI server, we get a list of virtual switches on the datacenter and from that we pull out the VHostID that matches the server we pass...
PowerShellCorpus/PoshCode/Xml Module 4.6.ps1
Xml Module 4.6.ps1
#requires -version 2.0 # Improves over the built-in Select-XML by leveraging Remove-XmlNamespace http`://poshcode.org/1492 # to provide a -RemoveNamespace parameter -- if it's supplied, all of the namespace declarations # and prefixes are removed from all XML nodes (by an XSL transform) before searching. # IMP...
PowerShellCorpus/PoshCode/Test-IPMask_1.ps1
Test-IPMask_1.ps1
<# .SYNOPSIS Tests for a valid IP mask. .DESCRIPTION The Test-IPMask script validates the input string against all CIDR subnet masks and returns a boolean value. .PARAMETER IPMask The IP mask to be evaluated. .EXAMPLE Test-IPMask 255.255.255.0 Description ----------- Tests if the I...
PowerShellCorpus/PoshCode/New-ObjectRecursive.ps1
New-ObjectRecursive.ps1
<# .Synopsis Creates new object based on hashtable definition .Description Function is wrapper for New-Object that allows user to create nested objects using nested hashtable as definition. If you want to take advantage of type use 'Type' key within hashtable that defines object. ...
PowerShellCorpus/PoshCode/Get-Credential 2.4.ps1
Get-Credential 2.4.ps1
## Get-Credential ## An improvement over the default cmdlet which has no options ... ################################################################################################### ## History ## v 2.4 Fix a bug in -Store when the UserName isn't passed in as a parameter ## v 2.3 Add -Store switch and support p...
PowerShellCorpus/PoshCode/Get-VMStorageAdapters.ps1
Get-VMStorageAdapters.ps1
<# .SYNOPSIS Reports on Fibre Channel Adapters in the ESX hosts for a vCenter environment. .DESCRIPTION This script iterates through each Datacenter,Cluster, and Host in a vCenter environment and then lists the Fibre Channel HBAs that are present. .LINK .EXAMPLE PS> Get-VMStorageAdapters.ps1 -FileName hba.tx...
PowerShellCorpus/PoshCode/ProcessSnapshot.ps1
ProcessSnapshot.ps1
function Get-ProcessList { #snapshot time $now = Get-Date -f 'HH:mm:ss' #building list [int]$hndl = 0 $script:ret = @() ps | % -b {$arr = @()} -p { $str = "" | select Name, StartTime, PID, PM, WS, Desc, Publ $str.Name = $_.ProcessName $str.StartTime = $(try { $_.StartTime} catch { ret...
PowerShellCorpus/PoshCode/Invoke-VMCommand.ps1
Invoke-VMCommand.ps1
# Invoke-VMCommand.ps1 # Purpose : Run a remote command and return the results # Requirements: plink.exe from the Putty project must be in $env:path # Use -help parameter for instructions Param ( $VMHost, $username, $Command, [switch]$Help, [switch]$Verbose ) # Obtains list of...
PowerShellCorpus/PoshCode/Windows Startup Script.ps1
Windows Startup Script.ps1
<#====================================================================================== File Name : Startup.ps1 Original Author : Kenneth C. Mazie : Description : This is a personal startup script with pop-up notification and : checks to assure things are not already r...
PowerShellCorpus/PoshCode/Invoke-RemoteExpression_1..ps1
Invoke-RemoteExpression_1..ps1
############################################################################## ## ## Invoke-RemoteExpression ## ## From Windows PowerShell Cookbook (O'Reilly) ## by Lee Holmes (http://www.leeholmes.com/guide) ## ############################################################################## <# .SYNOPSIS ...
PowerShellCorpus/PoshCode/image2excel.ps1
image2excel.ps1
None
PowerShellCorpus/PoshCode/Get-WarningsAndErrors.ps.ps1
Get-WarningsAndErrors.ps.ps1
##############################################################################\n##\n## Get-WarningsAndErrors\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\nDe...
PowerShellCorpus/PoshCode/ScriptTransforms module_4.ps1
ScriptTransforms module_4.ps1
function New-ParameterTransform { #.Synopsis # Generates Parameter Transformation Attributes in simple PowerShell syntax #.Description # New-ParameterTransform allows the creation of .Net Attribute classes which can be applied to PowerShell parameters to transform or manipulate data as it's being passed in. #.Exam...
PowerShellCorpus/PoshCode/New-ISEMenu_3.ps1
New-ISEMenu_3.ps1
Import-Module ShowUI Function New-ISEMenu { New-Grid -AllowDrop:$true -Name "ISEAddonCreator" -columns Auto, * -rows Auto,Auto,Auto,*,Auto,Auto -Margin 5 { New-Label -Name Warning -Foreground Red -FontWeight Bold -Column 1 ($target = New-TextBox -Name txtName -Column 1 -Row ($Row=1)) New-Label...
PowerShellCorpus/PoshCode/Get-DellWarranty_1.ps1
Get-DellWarranty_1.ps1
function Get-DellWarranty { <# .Synopsis Provides warranty information for one or more Dell service tags. .Description Queries the Dell Website for a list of service tags and returns the warranty information as a custom object. If a service tag has multiple warranties, they are...
PowerShellCorpus/PoshCode/Boots & Background Jobs_1.ps1
Boots & Background Jobs_1.ps1
## NOTE: This requires the current changeset download of PowerBoots (not the 0.2 beta) Import-Module PowerBoots # This simulates a download function, say Jaykul's Get-Webfile # You can output current progress for a large file, or if it's an array of links then out put the current (index/length)% # You will need t...
PowerShellCorpus/PoshCode/Solarized (Dark) Theme_1.ps1
Solarized (Dark) Theme_1.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/GPRS Online log_2.ps1
GPRS Online log_2.ps1
<# .SYNOPSIS Get-GprsTime (V3.0 Update for Windows 7) Check the total connect time of any GPRS devices from a specified date. Use Get-Help .\\Get-GprsTime -full to view Help for this file. .DESCRIPTION Display all the GPRS modem Event Log entries. While applications issued by the mobile phone manufacturers wi...
PowerShellCorpus/PoshCode/Show-Sample1.ps1
Show-Sample1.ps1
Show -Width 300 -Height 150 { DockPanel { Menu -DockPanel-Dock Top -Height 20 { MenuItem -Header "_File" { ## Hook up the "New" menuitem to the New command ... MenuItem -Header "_New" -Command ([system.windows.input.applicationcommands]::new) MenuItem -Header ...
PowerShellCorpus/PoshCode/8c9f21a1-4924-4551-ae6d-1fc52d7751a4.ps1
8c9f21a1-4924-4551-ae6d-1fc52d7751a4.ps1
#################################################################################################### ## Write-Sitemap.ps1 ## ## Generates a basic Sitemap for your website, based on a list of locations / products or whatever, ## (depending on your requirements). Can easily be extended to create more complex Sitemaps...
PowerShellCorpus/PoshCode/7f98fa6b-12e6-4938-a5e7-254d4d3ef2dd.ps1
7f98fa6b-12e6-4938-a5e7-254d4d3ef2dd.ps1
Import-Module : Process should have elevated status to access IIS configuration data. At C:\\Users\\ca27573\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1:18 char:29 + Get-Module -ListAvailable | Import-Module + ~~~~~~~~~~~~~ + CategoryInfo : OperationStoppe...
PowerShellCorpus/PoshCode/RegQuery.ps1
RegQuery.ps1
# --------------------------------------------------------------------------- ### <Script> ### <Author> ### Chad Miller ### </Author> ### <Description> ### Searches the registry key for the specified pattern on the specified computer ### Useful in finding installed S/W ### </Description> ### <Usage> ### ./Re...
PowerShellCorpus/PoshCode/Get Virtual ESXi IP Addr_1.ps1
Get Virtual ESXi IP Addr_1.ps1
function Get-VirtualEsxiIp { param($vm) $tmpFileTemplate = ($env:TEMP + "\\ipdetect-") $tmpFile = $tmpFileTemplate + (Get-Random) + ".png" # Take the screenshot. $view = $vm | Get-View -Property Name $path = $view.CreateScreenShot() $path -match "([^/]+/[^/]+$)" | Out-Null $relativePath = $matches[1] ...
PowerShellCorpus/PoshCode/Share Perms.ps1
Share Perms.ps1
$FolderPath = "\\\\FilerName\\ShareName" $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/Split-String.ps1
Split-String.ps1
function Split-String { #.Synopsis # Split a string and execute a scriptblock to give access to the pieces #.Description # Splits a string (by default, on whitespace), and assigns it to $0, and the first 9 words to $1 through $9 ... and then calls the specified scriptblock #.Example # echo "this is one test ff...
PowerShellCorpus/PoshCode/Get-CountDown.ps1
Get-CountDown.ps1
function Get-CountDown() { <# .Synopsis CountDown timer and progress bar .Description A simple countdown timer as an advanced function. Displays the time remaining along with a_ progress bar displaying percentage time elapsed. If no parameters are passed, t...
PowerShellCorpus/PoshCode/HelpModules 2.1.ps1
HelpModules 2.1.ps1
# HelpModules # A Module for generating module stubs so you can Update-Help (or Save-Help) # Includes two options for reading the help from those modules (StubFunctions or Get-ModuleHelp) # 1.0 - 2013/2/1 - Initial release Friday, Feb 1st, 2013 # 2.0 - 2013/2/1 - Updated release with improved pipeline/remot...
PowerShellCorpus/PoshCode/Reflection Module_2.ps1
Reflection Module_2.ps1
#requires -version 2.0 # ALSO REQUIRES Autoload for some functionality # You should create a Reflection.psd1 with the contents: @{ RequiredModules = @("Autoload"); GUID="64b5f609-970f-4e65-b02f-93ccf3e60cbb"; ModuleVersion="3.5.0.0" } #History: # 1.0 - First public release (March 19, 2010) # 2.0 - Private Build ...
PowerShellCorpus/PoshCode/Get-Tail_1.ps1
Get-Tail_1.ps1
# Name: Get-Tail.ps1 # Author: William Stacey # Created: 02/22/2007 # Description: Gets the last N lines of a file. Does scan from end-of-file so works on large files. Also has a loop flag that prompts for refresh. function Get-Tail([string]$path = $(throw "Path name must be specified."), [int]$count = 10, [bool...
PowerShellCorpus/PoshCode/6a35f0a2-b19c-4518-8c2b-56793070490d.ps1
6a35f0a2-b19c-4518-8c2b-56793070490d.ps1
[sourcecode language="css"] ## # ----------------------------------------------------- function Release-Ref ($ref) { ([System.Runtime.InteropServices.Marshal]::ReleaseComObject( [System.__ComObject]$ref) -gt 0) [System.GC]::Collect() [System.GC]::WaitForPendingFinalizers() } # --------------------------...
PowerShellCorpus/PoshCode/PowerShell Template_4.ps1
PowerShell Template_4.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="email@mycompany.com" } $comment=@(); while($s = (Read-Host "Comment").Trim()){$comment+="$s`r`n#"} $f...
PowerShellCorpus/PoshCode/Write-Log_1.ps1
Write-Log_1.ps1
function Write-Log { #region Parameters [cmdletbinding()] Param( [Parameter(ValueFromPipeline=$true,Mandatory=$true)] [ValidateNotNullOrEmpty()] [string] $Message, [Parameter()] [ValidateSet(“Error”, “Warn”, “Info”)] [string] $Level = “Info”, [Parameter()] [ValidateRange(1,30)] ...
PowerShellCorpus/PoshCode/Select-Xml 2.2.ps1
Select-Xml 2.2.ps1
#requires -version 2.0 # Select-Xml 2.2 and Remove-XmlNamespace # Version History: # Select-Xml 2.0 was the first script version I wrote, and it didn't function identically to the built-in Select-Xml with regards to parameter parsing # Select-Xml 2.1 matched the built-in Select-Xml parameter sets, it's now a drop-i...
PowerShellCorpus/PoshCode/Resolve-Aliases _3.7.ps1
Resolve-Aliases _3.7.ps1
#requires -version 2.0 ## ResolveAliases Module v 1.6 ######################################################################################################################## ## Sample Use: ## Resolve-Aliases Script.ps1 | Set-Content Script.Resolved.ps1 ## ls *.ps1 | Resolve-Aliases -Inplace ##############...
PowerShellCorpus/PoshCode/Xml Module 4.ps1
Xml Module 4.ps1
#requires -version 2.0 # Improves over the built-in Select-XML by leveraging Remove-XmlNamespace http://poshcode.org/1492 # to provide a -RemoveNamespace parameter -- if it's supplied, all of the namespace declarations # and prefixes are removed from all XML nodes (by an XSL transform) before searching. # IMPO...
PowerShellCorpus/PoshCode/DefaultParameterValues_1.ps1
DefaultParameterValues_1.ps1
function Export-DefaultParameter { #.Synopsis # Exports the current default parameter values [CmdletBinding()] param( # The path to export default parameter values to (defaults to "DefaultParameterValues.clixml" in your profile directory) [String]$Path = $(Join-Path (Split-Path $Profile.CurrentUserAllHos...
PowerShellCorpus/PoshCode/Get-Weather_2.ps1
Get-Weather_2.ps1
Function Get-Weather { <# .SYNOPSIS Display weather data for a specific country and city. .DESCRIPTION Display weather data for a specific country and city. There is a possibility for this to fail if the web service being used is unavailable. .PARAMETER Country URL of the website to test access to....
PowerShellCorpus/PoshCode/File navigator.ps1
File navigator.ps1
$empty = "<NULL>" $itmType = "Directory", "File" function LoadTreeView { $nodes = [IO.Directory]::GetLogicalDrives() $trvRoot.Nodes.Clear() foreach ($nod in $nodes) { $node = New-Object Windows.Forms.TreeNode $node = $trvRoot.Nodes.Add($nod) $node.Nodes.Add($empty) } } function ...
PowerShellCorpus/PoshCode/MainulatingCustomObjects.ps1
MainulatingCustomObjects.ps1
function JoinTwoCustomObjs($Parent,$Child,$Key) { $CurrentErrorSetting = $ErrorActionPreference $ErrorActionPreference = 'SilentlyContinue' $new = New-Object -TypeName PsObject $ParentProps = Get-Member -InputObject $Parent -MemberType NoteProperty foreach($prop in $ParentProps) { $PropName = $prop...
PowerShellCorpus/PoshCode/finddupe_10.ps1
finddupe_10.ps1
function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider]; $hashAlgorithm = new-object $cryptoServiceProvider $stream = $file.OpenRead(); $hashByteArray = $hashA...
PowerShellCorpus/PoshCode/Exchange AutoReply Admin.ps1
Exchange AutoReply Admin.ps1
<# .NOTES Name : Exchange Automatic Replies Administrator.ps1 Author : Bryan Jaudon <bryan.jaudon@gmail.com> Version : 1.0 Date : 11/23/2012 .SYNOPSIS Provides a graphical front-end to the Get-MailboxAutoReplyConfiguration and Set-MailboxAutoReplyConfiguration Exch...
PowerShellCorpus/PoshCode/Get_Set Signature _1.0.ps1
Get_Set Signature _1.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/Get-LocalGroupMembers_1.ps1
Get-LocalGroupMembers_1.ps1
function Get-LocalGroupMembers { param($groupname) $pattern = "*Name=`"$groupname`"" $groupusers = gwmi Win32_GroupUser | Where { $_.GroupComponent -like $pattern } # Now extract the usernames. foreach ($user in $groupusers) { if ($user.PartComponent -match 'Name="([^"]+)') { Write-Output $matches[...
PowerShellCorpus/PoshCode/Get-WebPage.ps1
Get-WebPage.ps1
function Get-WebPage { <# .SYNOPSIS Downloads web page from site. .DESCRIPTION Downloads web page from site and displays source code or displays total bytes of webpage downloaded .PARAMETER Url URL of the website to test access to. .PARAMETER UseDefaultCredentials Use the currently authentica...
PowerShellCorpus/PoshCode/GET-Remoteapps.ps1
GET-Remoteapps.ps1
# Original posting on how to access a remote Registry from The Powershell Guy # # http://thepowershellguy.com/blogs/posh/archive/2007/06/20/remote-registry-access-and-creating-new-registry-values-with-powershell.aspx # # This script will Query the Uninstall Key on a computer specified in $computername and list the...
PowerShellCorpus/PoshCode/7697c70c-75c8-4a8e-86cd-5e8f3f2f1eb7.ps1
7697c70c-75c8-4a8e-86cd-5e8f3f2f1eb7.ps1
Function PowerOn-VM($vm){ Start-VM -VM $vm -Confirm:$false -RunAsync | Out-Null do { $vmview = get-VM $vm | Get-View $status = $vmview.Guest.ToolsStatus Write-Host $vm is starting! -ForegroundColor Yellow sleep 5 }until(($status -match "toolsOld") -or ($status -match "toolsOk")) ...
PowerShellCorpus/PoshCode/Test-Host V1.ps1
Test-Host V1.ps1
Param($property,$tport=135,$timeout=1000,[switch]$port,[switch]$verbose) Begin{ function TestPort { Param($srv) $error.Clear() $ErrorActionPreference = "SilentlyContinue" $tcpclient = new-Object system.Net.Sockets.TcpClient $iar = $tcpclient.BeginConnect($srv,$tport,$n...
PowerShellCorpus/PoshCode/Convert-ToCHexString_1.ps1
Convert-ToCHexString_1.ps1
function Convert-ToCHexString { param([String] $input) $ans = '' [System.Text.Encoding]::ASCII.GetBytes($str) | % { $ans += "0x{0:X2}, " -f $_ } return $ans.Trim(',',' ') }
PowerShellCorpus/PoshCode/Get-LocalGroupMember_1.ps1
Get-LocalGroupMember_1.ps1
function Get-LocalGroupMember { param( # The name of the local group to retrieve members of [Parameter(Position=0,Mandatory=$true)] [String]$GroupName = "administrators", # A filter for the user name(s) [Parameter(Position=1)] [String]$UserName = "*", # The computer to query (defaults ...
PowerShellCorpus/PoshCode/Save-Credentials_6.ps1
Save-Credentials_6.ps1
<# .SYNOPSIS The script saves a username and password, encrypted with a custom key to to a file. .DESCRIPTION The script saves a username and password, encrypted with a custom key to to a file. The key is coded into the script but should be changed before use. The key allows the password to be decrypted ...
PowerShellCorpus/PoshCode/WinFirewall-Stoped.ps1
WinFirewall-Stoped.ps1
function WinFirewall-Stoped(){ param ( $computer ) c:\\PsTools\\PsExec.exe \\\\"$computer" sc stop sharedaccess }
PowerShellCorpus/PoshCode/1716db2c-bd83-404b-b8ec-beb189e225b4.ps1
1716db2c-bd83-404b-b8ec-beb189e225b4.ps1
$mykey = "xxx" $newkey = "yyy" $OFS = "" cd C:\\Users\\kagami\\Downloads ls | % { if ($_.name -match "^\\[rutracker\\.org\\].*\\.torrent") { $file = $_.name $data = cat -en byte -LiteralPath $file $data2 = ([string][char[]]$data) -replace "ann\\?uk=$mykey", "ann?uk=$newkey" ...
PowerShellCorpus/PoshCode/Set-IPAddress_9.ps1
Set-IPAddress_9.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/Trim Working Set for PID.ps1
Trim Working Set for PID.ps1
## Trim Working set Function TrimWorkingSet { param([int] $procid) <#.NOTES AUTHOR: Sunny Chakraborty(sunnyc7@gmail.com) WEBSITE: http://tekout.wordpress.com CREATED: 9/20/2012 This starts the Evil Monkey series of scripts. .DESCRIPTION MSDN - http://msdn.microsoft.com/en-us/library/windows/desktop/ms6862...
PowerShellCorpus/PoshCode/Quest Dynamic Group 003.ps1
Quest Dynamic Group 003.ps1
<# 2012.07.06 Information will be uploaded shortly. #>
PowerShellCorpus/PoshCode/http___harleydavidsonmot.ps1
http___harleydavidsonmot.ps1
Sow nothing, reap nothing. -----------------------------------
PowerShellCorpus/PoshCode/Custom Speech Commands_3.ps1
Custom Speech Commands_3.ps1
#Filename commands.ps1 import-module "G:\\Documents\\Speech Macros\\custom.psm1" import-module "G:\\Documents\\Speech Macros\\alice.psm1" Add-SpeechCommands @{ "test command" = { Say $(Respond "3:2,4:0-2") } " * the percentages * " = { Say $(Percentages) } " * star date * " = { Say "Current,...
PowerShellCorpus/PoshCode/Build-TFSProjects_1.ps1
Build-TFSProjects_1.ps1
#------------------------------------------------------------------------- # Script that will: # 1. Create a workspace. Workspacce Name: _Root # 2. Get the latest code from repository #------------------------------------------------------------------------- Param( [switch] $CSRWEB, [switch]...
PowerShellCorpus/PoshCode/Set-LocalUserAccount.ps1
Set-LocalUserAccount.ps1
function Set-LocalUserAccount { param ( [parameter(Mandatory=$true)] [string] $Username, [string] $Description, [string] $FullName, [string] $ComputerName = $env:COMPUTERNAME, [system.Security.SecureString] $Password, [switch] $PasswordChangeAtNextLogon, [switch] $CannotChangePassword, [swi...
PowerShellCorpus/PoshCode/Split-Job V 1.2.ps1
Split-Job V 1.2.ps1
#requires -version 2.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 S...
PowerShellCorpus/PoshCode/JSON 1.5.ps1
JSON 1.5.ps1
#requires -version 2.0 # Version History: # v 0.5 - First Public version # v 1.0 - Made ConvertFrom-Json work with arbitrary JSON # - switched to xsl style sheets for ConvertTo-JSON # v 1.1 - Changed ConvertFrom-Json to handle single item results # v 1.2 - CodeSigned to make a fellow geek happy # v 1.3 - ...
PowerShellCorpus/PoshCode/Hack ESXi_1.ps1
Hack ESXi_1.ps1
* UNAUTHORISED ACCESS PROHIBITED: * * ------------------------------- * * This network is provided for authorised staff of Test
PowerShellCorpus/PoshCode/Xml Module 4.2.ps1
Xml Module 4.2.ps1
#requires -version 2.0 # Improves over the built-in Select-XML by leveraging Remove-XmlNamespace http`://poshcode.org/1492 # to provide a -RemoveNamespace parameter -- if it's supplied, all of the namespace declarations # and prefixes are removed from all XML nodes (by an XSL transform) before searching. # IMP...
PowerShellCorpus/PoshCode/get-GPOReportSize.ps1
get-GPOReportSize.ps1
param( [Parameter(Position=0,ValueFromPipeline=$True)]$GPOs = @(Get-GPO -All), [string] $Reportfolder = [Environment]::getfolderpath("mydocuments") + "\\GPOreports" ) begin{ $script:GPObj = @() $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().Name $startfolder = "\\\\$domain\\SYS...
PowerShellCorpus/PoshCode/Email-ExpiringADAccounts.ps1
Email-ExpiringADAccounts.ps1
Function GetMsgBody { Write-Output @" <p>Dear $name,</p> Your ABC network account is about to expire.<br/> Please email helpdesk@abc.com or simply hit 'reply', and include the following details to have your account extended.<br/> <br/> Your name:<br/> The department you currently volunteer in:<br/> ...
PowerShellCorpus/PoshCode/Get_Set Signature (CTP2)_1.ps1
Get_Set Signature (CTP2)_1.ps1
#Requires -version 2.0 ## Authenticode.psm1 #################################################################################################### ## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets ## These properly parse paths, so they don't kill your pipeline and script if you incl...
PowerShellCorpus/PoshCode/New-XVM_6.ps1
New-XVM_6.ps1
#Examples <# New-XVM -Name "WS2012-TestServer01" -SwitchName "Switch(192.168.2.0/24)" -VhdType NoVHD New-XVM -Name "WS2012-TestServer02" -SwitchName "Switch(192.168.2.0/24)" -VhdType ExistingVHD -VhdPath 'D:\\vhds\\WS2012-TestServer02.vhdx' New-XVM -Name "WS2012-TestServer03" -SwitchName "Switch(192.168.2.0/24)" ...
PowerShellCorpus/PoshCode/Set Logfile length_4.ps1
Set Logfile length_4.ps1
<# .SYNOPSIS Set any text file to a fixed number of lines. Use 'Get-Help .\\SetFileLines -full' to view Help for this file. .DESCRIPTION This script will maintain the PS Transcript file (default setting), or any text file, at a fixed length, ie matching the number of lines entered. However, omitting the lines p...
PowerShellCorpus/PoshCode/New-WebServiceProxy.ps1
New-WebServiceProxy.ps1
# # New-WebServiceProxy.ps1 (v2.0 Aug 6, 2007) # # Oisin Grehan <oising@gmail.com> (x0n) # # Usage: # $proxy = .\\New-WebServiceProxy.ps1 [-Url] http://site/service.asmx [-Anonymous] [[-SoapProtocol] <Soap | Soap12>] # # to see available webmethods: # $proxy | gm # # $url = "http://services.msdn.micros...
PowerShellCorpus/PoshCode/Export-WLANSettings.ps1
Export-WLANSettings.ps1
# ============================================================================================== # # # NAME: Export-WLANSettings.ps1 # # AUTHOR: Jan Egil Ring # # DATE : 14.03.2010 # # COMMENT: Using netsh.exe to loop through each WLAN on the system and export the settings to the user-provided ...
PowerShellCorpus/PoshCode/b50414a2-209f-4936-a4a8-5fcd9719f5ba.ps1
b50414a2-209f-4936-a4a8-5fcd9719f5ba.ps1
################################################################################ # Get-GprsTime.ps1(V 1006A) # Check the total connect time of any GPRS devices from a specified date. # Use the -Detail switch for some extra information if desired. A default value # can be set with the -Monthly switch but can...
PowerShellCorpus/PoshCode/Test-UserCredential_2.ps1
Test-UserCredential_2.ps1
function Test-UserCredential { [CmdletBinding()] [OutputType([System.Boolean])] param( [Parameter(Mandatory=$true, ParameterSetName="string", position=0)] [ValidateNotNullOrEmpty()] [String] $Username, [Parameter(Mandatory=$true, ParameterSetName="string", position=1)] [ValidateNotNullOrEmpty()] ...
PowerShellCorpus/PoshCode/c63c9baf-0890-494c-ba9c-4cadeb312a6c.ps1
c63c9baf-0890-494c-ba9c-4cadeb312a6c.ps1
function Get-WebConfigSqlConnectionString { param( [switch]$help, [string]$configfile = $(read-host "Please enter a web.config file to read"), [string]$conname = $(read-host "Please enter connection name")); $usage = "Usage: Get-WebConfigSqlConnectionString -configfile c:\\inetpub\\wwwroot\\web.config -conn...
PowerShellCorpus/PoshCode/Send-Paste.ps1
Send-Paste.ps1
## Send-Paste.ps1 (aka sprunge for Pastebin)\n##############################################################################################################\n## Uploads code to any pastebin.com based pastebin site and returns the url for you.\n## History:\n## v 2.0 - works with "pastebin" (including http://posh.jaykul....
PowerShellCorpus/PoshCode/Write-DataTable_2.ps1
Write-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/Select-ToString.ps1
Select-ToString.ps1
[CmdletBinding(DefaultParameterSetName='DefaultParameter')] param( [Parameter(ValueFromPipeline=$true)] [System.Management.Automation.PSObject] ${InputObject}, [Parameter(ParameterSetName='DefaultParameter', Position=0)] [System.String[]] ${Property}, [Parameter(ParameterSetName=...
PowerShellCorpus/PoshCode/2b09949e-6005-4a68-8379-aec09cbeea8e.ps1
2b09949e-6005-4a68-8379-aec09cbeea8e.ps1
function Get-EasterEastern { Param( [Parameter(Mandatory=$true)] [int] $Year ) $a = $Year % 4 $b = $Year % 7 $c = $Year % 19 $d = ((19 * $c) + 15) % 30 $e1 = -$d #here because powershell is picking up - (subtraction operator) as incorrect toekn $e = ((2 * $a) + (4 * $b) + ...
PowerShellCorpus/PoshCode/PoshCode ISE Addon_1.ps1
PoshCode ISE Addon_1.ps1
\nif (!(Get-Module WPK)) {Import-Module -global WPK} if (!(Get-Module PoshCode)) {Import-Module -global PoshCode} Function Get-PoshCodePreferences { if (Get-Item $global:xmlPath -ErrorAction SilentlyContinue) { try { $pcPreferences = Import-Clixml -Path $global:xmlPath $globa...
PowerShellCorpus/PoshCode/Ping-Subnet.ps1
Ping-Subnet.ps1
#requires -Version 2.0 Function Ping-Subnet { #.Synopsis # Ping a subnet returning all alive hosts. #.Example # Ping-Subnet -IP 192.168.1.0 -Netmask /24 #.Example # Ping-Subnet -IP 192.168.1.128 -Netmask 255.255.255.128 Param( [string] $IP, [string] ...
PowerShellCorpus/PoshCode/Set-SolarizedHostColor.ps1
Set-SolarizedHostColor.ps1
# function Set-HostColor { param( [Switch]$Light = $( ## Based on whether we're elevated or not, switch between DARK and LIGHT versions of Solarized: $([System.Environment]::OSVersion.Version.Major -gt 5) -and ( # Vista or higher and ... new-object ...
PowerShellCorpus/PoshCode/a39ded79-9953-4554-99ac-98c97462bfb8.ps1
a39ded79-9953-4554-99ac-98c97462bfb8.ps1
function Get-Help { <# .ForwardHelpTargetName Get-Help .ForwardHelpCategory Cmdlet #> [CmdletBinding(DefaultParameterSetName='AllUsersView')] param( [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] [System.String] ${Name}, [System.String] ${Path}, [System.String[]...
PowerShellCorpus/PoshCode/Get-ParameterAlias.ps1
Get-ParameterAlias.ps1
##############################################################################\n##\n## Get-ParameterAlias\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\nLooks...
PowerShellCorpus/PoshCode/Get-ADGroupMembers.ps1
Get-ADGroupMembers.ps1
Function Get-ADGroupMembers { <# .SYNOPSIS Return a collection of users in an ActiveDirectory group. .DESCRIPTION This function returns an object that contains all the properties of a user object. This function works for small groups as well as groups in ex...
PowerShellCorpus/PoshCode/POC csharp expressions_1.ps1
POC csharp expressions_1.ps1
function run-csharpexpression([string] $expression ) { $local:name = [system.guid]::NewGuid().tostring().replace('-','_').insert(0,"csharpexpr") $local:template = @" using System; using System.IO; using System.Collections.Generic; using System.Linq; namespace ShellTools.DynamicCSharpExpression.N[[COUNTER]] {...
PowerShellCorpus/PoshCode/Add SSL Cert to IIS.ps1
Add SSL Cert to IIS.ps1
function Add-SSLCertificate{ param([string]$pfxPath,[string]$pfxPassword,[string]$hostHeader,[string]$siteName) $certMgr = New-Object -ComObject IIS.CertObj -ErrorAction SilentlyContinue $certMgr.ImportToCertStore($pfxPath,$pfxPassword,$true,$true) Import-Module WebAdministration; New-W...
PowerShellCorpus/PoshCode/DriveUtilization.ps1
DriveUtilization.ps1
Function Get-Utilization { Param([string]$computername=$env:computername, [string]$ID="C:" ) #suppress errors messages $errorActionPreference="silentlycontinue" $drive=Get-WmiObject Win32_Logicaldisk -filter "DeviceID='$ID'" ` -computerna...
PowerShellCorpus/PoshCode/test_2.ps1
test_2.ps1
[CmdletBinding()] param() "This file is in the $PSScriptRoot folder." # SIG # Begin signature block # MIIPGwYJKoZIhvcNAQcCoIIPDDCCDwgCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUtq5NTq7Q77yPgrtRePzRWHVn # THuggg...
PowerShellCorpus/PoshCode/USB Script backup_2.ps1
USB Script backup_2.ps1
<# .SYNOPSIS Backup-ToUSB.ps1 (Version 2.2, 9 Jan 2012) .DESCRIPTION This script will backup recently changed *.ps1,*.psm1,*.psd1 files from any selected folder (default is $pwd) to any number of inserted USB devices, on which an archive folder 'PSarchive' will be created if it does not already exist. As a U...
PowerShellCorpus/PoshCode/Receive-Stream_1.ps1
Receive-Stream_1.ps1
function Receive-Stream { #.Synopsis # Read a stream to the end and close it #.Description # Will read from a byte stream and output a string or a file #.Param reader # The stream to read from #.Param fileName # A file to write to. If this parameter is provided, the function will output to file #.Param enc...
PowerShellCorpus/PoshCode/ONTAPI Module.ps1
ONTAPI Module.ps1
# Requires Version 2.0 # Requires ManageOntap.Dll # Plenty of room left for documentation # Andy Schneider - http://get-powershell.com # 3/10/2009 $OnTapDll = (resolve-path $PSScriptRoot\\ManageOntap.dll).Path [System.Reflection.Assembly]::LoadFile($onTapDll) function New-NTAPServer { param ( [Paramet...
PowerShellCorpus/PoshCode/New-LinkedClone.ps1
New-LinkedClone.ps1
#Requires -version 2 # TITLE: New-LinkedClone.ps1 # AUTHOR: Hal Rottenberg # Adapted from a technique published originally by Keshav Attrey http://www.vmdev.info/?p=40 # Also see William Lam's Perl script: http://engineering.ucsb.edu/~duonglt/vmware/vGhettoLinkedClone.html # And Leo's manual version for ESX 3.5...
PowerShellCorpus/PoshCode/Console Function Run_1.ps1
Console Function Run_1.ps1
function Run ([String]$scriptName = '-BLANK-') { <# The next function records any running scripts started in the console session (from $pwd) in the Scripts Event Log. It should be placed in the Console $profile. Scripts should be started by typing 'Run example' to capture example.ps1, for example. The...
PowerShellCorpus/PoshCode/Get-Netstat _1.2.ps1
Get-Netstat _1.2.ps1
Function Get-Netstat { $null, $null, $null, $null, $netstat = netstat -a -n -o [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}(\\:([...
PowerShellCorpus/PoshCode/Kill Outlook + CopyPST.ps1
Kill Outlook + CopyPST.ps1
$rep_du_user = $env:userprofile $repertoire_pst = ($rep_du_user+"\\AppData\\Local\\Microsoft\\Outlook") $repertoire_sauvegarde = "directory" #Kill de outlook Get-Process | Where { $_.Name -Eq "outlook" } | Kill #wait and see :) sleep 10 #copy des pst xcopy $repertoire_pst $repertoire_sauvegarde /D /E /C /...
PowerShellCorpus/PoshCode/Out-Balloon_1.ps1
Out-Balloon_1.ps1
<# .Synopsis Makes a baloon tip in the notification area .Description With just a few arguments, it is easy to make some text appear in a little balloon. You can specify an icon file (*.ico) with the -icon argument, if you don't then the first icon of the host is used. out-balloo...
PowerShellCorpus/PoshCode/Join-Collections_1.ps1
Join-Collections_1.ps1
#requires -version 2.0 ## Version 1.0 First post http://poshcode.org/1459 ## Version 1.1 Fixed column uniqueness bug #.Note # Depends on ConvertFrom-HashTable http://poshcode.org/1118 #.Synopsis # Performs a inner join on two collections of objects based on a common key column. #.Description # Takes two ...
PowerShellCorpus/PoshCode/Set-UserCannotChangePass_1.ps1
Set-UserCannotChangePass_1.ps1
#########1#########2#########3#########4#########5#########6#########7#########8#########9#########1 #########0#########0#########0#########0#########0#########0#########0#########0#########0#########0 # # Author: Erik McCarty # # Description: Set the "user Cannot Change Password" property on an active # director...