full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Get-IISLogLocation.ps1
Get-IISLogLocation.ps1
Function Get-IISLogLocation { <# .SYNOPSIS This function can be ran against a server or multiple servers to locate the log file location for each web site configured in IIS. .DESCRIPTION This function can be ran against a server or multiple servers to locate the log file location for each web...
PowerShellCorpus/PoshCode/Get-DellWarranty_4.ps1
Get-DellWarranty_4.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/Test-UserCredential_4.ps1
Test-UserCredential_4.ps1
function Test-UserCredential { [CmdletBinding(DefaultParameterSetName = "set1")] [OutputType("set1", [System.Boolean])] [OutputType("PSCredential", [System.Boolean])] param( [Parameter(Mandatory=$true, ParameterSetName="set1", position=0)] [ValidateNotNullOrEmpty()] [String] $Username, [Parameter...
PowerShellCorpus/PoshCode/Make a phone call_3.ps1
Make a phone call_3.ps1
<# .NOTES AUTHOR: Sunny Chakraborty(sunnyc7@gmail.com) WEBSITE: http://tekout.wordpress.com VERSION: 0.1 CREATED: 17th April, 2012 LASTEDIT: 17th April, 2012 Requires: PowerShell v2 or better .CHANGELOG 4/17/2012 Try passing powershell objects to PROTO API and pass the variables to .JS file P...
PowerShellCorpus/PoshCode/Get-SiSReport_2.ps1
Get-SiSReport_2.ps1
Function Get-SiSReport { <# .SYNOPSIS Get the overall SIS usage information. .DESCRIPTION This function uses the sisadmin command to get the usage information for a SIS enabled drive. .PARAMETER SisDisk The drive letter of a disk that ...
PowerShellCorpus/PoshCode/Apache Log Browser Count.ps1
Apache Log Browser Count.ps1
Select-String "(MSIE [0-9]\\.[0-9]|Firefox\\/[0-9]+|Safari|-)" $log -all | Group { $_.matches[-1].Value } | ForEach -begin { $total = 0 } ` -process { $total += $_.Count; $_ } | Sort Count | Select Count, Name | Add-Member ScriptProperty Percent { "{0,7:0.000}%" -f (100*$this.Count/$Total) } -Passthru ###...
PowerShellCorpus/PoshCode/SharePoint build script_1.ps1
SharePoint build script_1.ps1
#BASEPATH variable should be explicitly set in every #build script. It represents the "root" #of the project folder, underneath which all tools, source, config settings, #and deployment folder lie. $global:basepath = (resolve-path ..).path function Set-BasePath([string]$path) { $global:basepath = $path } f...
PowerShellCorpus/PoshCode/Select-EnumeratedType_1.ps1
Select-EnumeratedType_1.ps1
#requires -version 2 if (-not(test-path variable:script:_helpcache)) { $SCRIPT:_helpCache = @{} } function Select-EnumeratedType { <# .SYNOPSIS Visually create an instance of an enum. .DESCRIPTION Visually create an instance of an enum with an easy to use menu system...
PowerShellCorpus/PoshCode/Performance Monitoring.ps1
Performance Monitoring.ps1
<# .SYNOPSIS Multiple functions to build a config file and to use file to launch PerfMon background jobs. .DESCRIPTION Multiple functions to build a config file and to use file to launch PerfMon background jobs. .NOTES Name: WinPerfv2.PS1 Author: Boe Prox DateCreated: 28June2010 ...
PowerShellCorpus/PoshCode/Invoke-AppAsAdmin.ps1
Invoke-AppAsAdmin.ps1
#requires -version 2.0 <# .SYNOPSIS Script to run executable with alternate credentials as admin. .DESCRIPTION This script will try to invoke itself with alternate credentials (using Get-Credential cmdlet) and once it's there it will try to run any executable as elevated. Designe...
PowerShellCorpus/PoshCode/Findup_13.ps1
Findup_13.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) ...
PowerShellCorpus/PoshCode/Create RTF File .ps1
Create RTF File .ps1
param ( [string]$Filename ) # Save script as NEWRTF.PS1 # # Execute with ./NEWRTF.PS1 -filename somefilename.rtf # # Note for this basic example, there is no error checking # The full path name INCLUDING RTF extension must be supplied # for the filename # # For Example C:\\Folder\\Filename.RTF # # Fo...
PowerShellCorpus/PoshCode/Get-Installed.ps1
Get-Installed.ps1
function Get-Installed { <# .SYNOPSIS This function lists data found in the registry associated with installed programs. .DESCRIPTION Describe the function in more detail Author: Stan Miller .EXAMPLE Get all apps whose display names start with a specific string and display all valuenam...
PowerShellCorpus/PoshCode/Import-Certificate_8.ps1
Import-Certificate_8.ps1
#requires -Version 2.0 function Import-Certificate { param ( [IO.FileInfo] $CertFile = $(throw "Paramerter -CertFile [System.IO.FileInfo] is required."), [string[]] $StoreNames = $(throw "Paramerter -StoreNames [System.String] is required."), [switch] $LocalMachine, [switch] $CurrentUser, [string...
PowerShellCorpus/PoshCode/Get-NestedGroups v_4.ps1
Get-NestedGroups v_4.ps1
Function Global:Get-NestedGroups { <# .SYNOPSIS Enumerate all AD group memberships of an account (including nested membership). .DESCRIPTION This script will return the AD group objects for each group the user is a member of. .PARAMETER UserName The username whose group memberships to find. .E...
PowerShellCorpus/PoshCode/Get-NestedGroups v2.ps1
Get-NestedGroups v2.ps1
Function Get-NestedGroups { <# .SYNOPSIS Enumerate all AD group memberships of an account (including nested membership). .DESCRIPTION This script will return the AD group objects for each group the user is a member of. .PARAMETER UserName The username whose group memberships to find. .EXAMPLE ...
PowerShellCorpus/PoshCode/MachineKey.psm1.ps1
MachineKey.psm1.ps1
if((Get-Command Get-Website, Get-WebApplication, Get-WebConfiguration, Get-WebConfigFile, Set-WebConfigurationProperty -EA 0).Count -lt 5) { throw "The required commands from the 'WebAdministration' module are not available. Import the WebAdministration module and try again.`n The following commands are required: ...
PowerShellCorpus/PoshCode/Process Count CheckAlert.ps1
Process Count CheckAlert.ps1
<#***************************************************************************************************************** * PowerShell Script to verify Process Count Check & Email alert ***************************************************************************************************************** Script f...
PowerShellCorpus/PoshCode/Get-Credential 2.3.ps1
Get-Credential 2.3.ps1
## Get-Credential ## An improvement over the default cmdlet which has no options ... ################################################################################################### ## History ## v 2.3 Add -Store switch and support putting credentials into the file system ## v 2.1 Fix the comment help and para...
PowerShellCorpus/PoshCode/Set-Computername_15.ps1
Set-Computername_15.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/FS_FindFiles.ps1
FS_FindFiles.ps1
Param ( [string[]]$Computers=$env:ComputerName, [string[]] $Paths = @("C:\\Windows","C:\\Windows\\system32"), [string[]] $FileNames = @("fsb.tmp","fsb.stb","notpad.exe") ) $Global:objOut = @() Function FindFiles ($Computer, $Filter){ try{ $Files = Gwmi -namespace "root\\CIMV2" -computername $Computer...
PowerShellCorpus/PoshCode/f81bf3c1-15b5-492d-b806-22073181af89.ps1
f81bf3c1-15b5-492d-b806-22073181af89.ps1
# Name: zip.ps1 # Author: Shadow # Created: 05/12/2008 param([string]$zipfilename=$(throw "ZIP archive name needed!"), [string[]]$filetozip=$(throw "Supply the file(s) to compress (wildcards accepted)")) trap [Exception] {break;} #empyt zip file contents $emptyzipfile=80,75,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0...
PowerShellCorpus/PoshCode/New-XSD.ps1
New-XSD.ps1
# --------------------------------------------------------------------------- ### <Script> ### <Author> ### Chad Miller ### </Author> ### <Description> ### Generates an XSD File with SQLXML annotations for a Powershell object ### The XSD file can be used with SQLXML to automatically create a SQL table ### and ...
PowerShellCorpus/PoshCode/Get-Lotterynumbers.ps1
Get-Lotterynumbers.ps1
########################################################################### # # NAME: Get-Lotterynumbers.ps1 # # AUTHOR: Jan Egil Ring # EMAIL: jer@powershell.no # # COMMENT: Generates lottery numbers based on user input. # # You have a royalty-free right to use, modify, reproduce, and # distribute this scrip...
PowerShellCorpus/PoshCode/New-ElevatedTask 2.7.ps1
New-ElevatedTask 2.7.ps1
#requires -version 2.0 ############################################################################### ## New-ElevatedTask is a script (for Vista) which creates "elevated" scheduled ## tasks by exploiting the import-from XML feature of schtasks.exe /Create /XML ## ## Creates a new "On Demand Only" scheduled task ...
PowerShellCorpus/PoshCode/Set-VMBuildCSV.ps1
Set-VMBuildCSV.ps1
####################################################################### # # Purpose: Generate CSV file for VM builds without those darn Typos # Author: David Chung # Docs: N/A # # v.1 - 02/10/2011 Beta Initial Script # # Instruction: Launch the script from PowerCLI. # Login to vSPhere server from...
PowerShellCorpus/PoshCode/PWD Expiration Email_1.ps1
PWD Expiration Email_1.ps1
#Active Directory Group Name To Be Edited #Load Active Directory Module if(@(get-module | where-object {$_.Name -eq "ActiveDirectory"} ).count -eq 0) {import-module ActiveDirectory} # get domain maximumPasswordAge value $MaxPassAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.days if($MaxPassAge -le ...
PowerShellCorpus/PoshCode/Bootstrap psake w_ PsGet_1.ps1
Bootstrap psake w_ PsGet_1.ps1
# Get-MyModule adapted from http://blogs.technet.com/b/heyscriptingguy/archive/2010/07/11/hey-scripting-guy-weekend-scripter-checking-for-module-dependencies-in-windows-powershell.aspx function Get-MyModule { param ([string] $name) write-host "Is '$name' already imported? " -NoNewline -ForegroundColor Cyan ...
PowerShellCorpus/PoshCode/f86998a1-d0da-4204-b566-a9031310d3f9.ps1
f86998a1-d0da-4204-b566-a9031310d3f9.ps1
################################################################################################################ # # NAME # Copy-Data # # SYNOPSIS # Copy Data between Folders including a Progressbar # # SYNTAX # Copy-Data [Source <PathToSource>] [Destination <PathToDestination>] [-Confirm] [-Recu...
PowerShellCorpus/PoshCode/d31912bc-a156-4199-bcff-5b779e89a274.ps1
d31912bc-a156-4199-bcff-5b779e89a274.ps1
[void][system.reflection.Assembly]::LoadWithPartialName("MySql.Data") # Open Connection $connStr = "server=127.0.0.1;port=3306;uid=root;pwd=perilous;database=test;Pooling=False" $conn = New-Object MySql.Data.MySqlClient.MySqlConnection($connStr) $conn.Open() # write the info $sql = "INSERT INTO table1 (n...
PowerShellCorpus/PoshCode/Monitor-FileSize_2.ps1
Monitor-FileSize_2.ps1
function Monitor-FileSize { <# .Synopsis Checks the file size of a given file until it reaches the specified size .Description Checks the file size of a given file until it reaches the specified size. AT that point, it alerts the user as to what the original file-size-boundry was and what it currentl...
PowerShellCorpus/PoshCode/HuddledTricks_2.ps1
HuddledTricks_2.ps1
#Requires -version 2.0 ## Stupid PowerShell Tricks ################################################################################################### add-type @" using System; using System.Runtime.InteropServices; public class Tricks { [DllImport("user32.dll")] private static extern bool ShowWindowAsync(...
PowerShellCorpus/PoshCode/Set-PrimaryDnsSuffix.ps1
Set-PrimaryDnsSuffix.ps1
function Set-PrimaryDnsSuffix { param ([string] $Suffix) # http://msdn.microsoft.com/en-us/library/ms724224(v=vs.85).aspx $ComputerNamePhysicalDnsDomain = 6 Add-Type -TypeDefinition @" using System; using System.Runtime.InteropServices; namespace ComputerSystem { public class renamefull { ...
PowerShellCorpus/PoshCode/Get-SQLFileSize.ps1
Get-SQLFileSize.ps1
Function Get-SQLFileSize { <# .SYNOPSIS Retrieves the file size of a MDF or LDF file for a SQL Server .DESCRIPTION Retrieves the file size of a MDF or LDF file for a SQL Server .PARAMETER Computer Computer hosting a SQL Server .NOTES Name: Get-SQLFileSize Author: Boe Prox ...
PowerShellCorpus/PoshCode/Convert-BounceToX_12.ps1
Convert-BounceToX_12.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/sudo.ps1
sudo.ps1
[CmdletBinding()] Param( [Parameter(ValueFromRemainingArguments=$true)] $command=$(Read-Host "You must specify a command") ) #requires -version 2.0 function global:Sudo { ## In order to use this, you have to ## Create a "Scheduled Task" named "Elevated powershell.exe" to run ## PowerShell -Command ...
PowerShellCorpus/PoshCode/Brushes_1.ps1
Brushes_1.ps1
$frmMain_OnLoad= { $m_BrushSize = New-Object Drawing.Rectangle(0, 0, $picDemo.Width, $picDemo.Height) $wm = [Drawing.Drawing2D.WrapMode] $cboWraM.Items.AddRange(@($wm::Clamp, $wm::Tile, $wm::TileFlipX, $wm::TileFlipY, $wm::TileFlipXY)) $cboWraM.SelectedIndex = 0 [int]$maxHatchStyle = 53 for ($i ...
PowerShellCorpus/PoshCode/Copy files .ps1
Copy files .ps1
cls <# Writer: Ritesh P. #> # Core Declaration $date = ((get-date).toString('MM-dd-yyyy')) $time = ((Get-Date).toString('HH-mm-ss')) #$what = "/COPYALL /S /B" #$options = "/R:0 /W:0 /FP" $NewDestinationPath = '\\\\'+'infra'+'\\c$\\data1\\'+$date+'-'+$time # When I add $time to create Destination f...
PowerShellCorpus/PoshCode/BridgeBot 1.1.ps1
BridgeBot 1.1.ps1
## Depends on the PoshXmpp.dll from http://CodePlex.com/PowerXmpp #requires -pssnapin PoshXmpp ## Requires System.Web for the RSS-feed option [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null ########################################################################################## # @Author: Joe...
PowerShellCorpus/PoshCode/CD.psm1.ps1
CD.psm1.ps1
PARAM ( $MaxEntryCount = 50) <# Author: Bartek Bielawski (@bielawb on Twitter) Adds cd- functionality known in bash, an probably some other shells. Version: 0.1 Any comments/ feedback welcome, ping me on twitter on via e-mail (bartb at aster dot pl) #> <# We have to modify prompt funct...
PowerShellCorpus/PoshCode/Generate-Acronyms.ps1
Generate-Acronyms.ps1
param([String] $phrase) $words = $phrase.Split() $MaxLettersPerWord = 3 $output = @('') $maxSize = [System.Math]::Pow($MaxLettersPerWord, $words.Count) 1..$words.Count | % { $word, $words = $words $output | % { $oldWord = $_ 1..$MaxLettersPerWord | % { $output += $oldWord + $word.SubString(...
PowerShellCorpus/PoshCode/sudo for Powershell_1.ps1
sudo for Powershell_1.ps1
# sudo.ps1 # # Authors: pezhore, mrigns, This guy: http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell # Other powershell peoples. # # Sources: # http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell # http://www.ainotenshi.org/%E2%80%98sudo%E2%80%99-for...
PowerShellCorpus/PoshCode/HttpRest 1.1.0.ps1
HttpRest 1.1.0.ps1
#requires -version 2.0 ## HttpRest module #################################################################################################### ## Initial stages of changing HttpRest into a v2-only module ## Based on the REST api from MindTouch's Dream SDK ## ## INSTALL: ## You need mindtouch.dream.dll (mindtouch...
PowerShellCorpus/PoshCode/Google Chromium Download.ps1
Google Chromium Download.ps1
<# .Synopsis Download Google Chromium if there is a later build. .Description Download Google Chromium if there is a later build. #> Set-StrictMode -Version Latest Import-Module bitstransfer # comment out when not debugging $VerbosePreference = "Continue" #$VerbosePreferenc...
PowerShellCorpus/PoshCode/Findup_29.ps1
Findup_29.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/finddupe_17.ps1
finddupe_17.ps1
# new version has more error handling, "-delete" and "-noprompt" options. function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider]; $hashAlgorithm = new-object $cryp...
PowerShellCorpus/PoshCode/Get-LeaderBoard_2.ps1
Get-LeaderBoard_2.ps1
<# .SYNOPSIS Pulls down the leaderboards for the 2011 Scripting Games .DESCRIPTION Quick and dirty script to pull down the leaderboards for the 2011 scripting games. Can choose either beginner or advanced via a command line switch. To see the output in a table, you must pipe to "format-table -autosi...
PowerShellCorpus/PoshCode/Backup-EventLogs_1.ps1
Backup-EventLogs_1.ps1
Function Backup-EventLogs { <# .SYNOPSIS Backup Eventlogs from remote computer .DESCRIPTION This function backs up all logs on a Windows computer that have events written in them. This log is stored as a .csv file in the current directory, where the filenam...
PowerShellCorpus/PoshCode/Reflection Module _1.1.ps1
Reflection Module _1.1.ps1
#requires -version 2.0 # ALSO REQUIRES Autoload for some functionality (Latest version: http://poshcode.org/3173) # You should create a Reflection.psd1 with the contents: # @{ ModuleToProcess="Reflection.psm1"; RequiredModules = @("Autoload"); GUID="64b5f609-970f-4e65-b02f-93ccf3e60cbb"; ModuleVersion="4.5.0.0" ...
PowerShellCorpus/PoshCode/Test-UserCredential_3.ps1
Test-UserCredential_3.ps1
function Test-UserCredential { [CmdletBinding(DefaultParameterSetName = "set1")] [OutputType("set1", [System.Boolean])] [OutputType("PSCredential", [System.Boolean])] param( [Parameter(Mandatory=$true, ParameterSetName="set1", position=0)] [ValidateNotNullOrEmpty()] [String] $Username, [Parameter...
PowerShellCorpus/PoshCode/Test-Port.ps1
Test-Port.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/Get-Credential++_1.ps1
Get-Credential++_1.ps1
## Get-Credential ## An improvement over the default cmdlet which has no options ... ################################################################################################### ## History ## v 2.0 Rewrite for v2 to replace the default Get-Credential ## v 1.2 Refactor ShellIds key out to a variable, and wr...
PowerShellCorpus/PoshCode/b87a3777-9def-4855-88ea-f9ae2610a469.ps1
b87a3777-9def-4855-88ea-f9ae2610a469.ps1
#alias,addnewemailaddress import-csv .\\source.csv | foreach { $user = Get-Mailbox $_.alias $user.emailAddresses+= $_.addnewemailaddress $user.primarysmtpaddress = $_.addnewemailaddress Set-Mailbox $user -emailAddresses $user.emailAddresses set-Mailbox $user -PrimarySmtpAddress $user.primarysmtpaddress }
PowerShellCorpus/PoshCode/Test-Port_4.ps1
Test-Port_4.ps1
function Test-Port{ <# .SYNOPSIS Tests port on computer. .DESCRIPTION Tests port on computer. .PARAMETER computer Name of server to test the port connection on. .PARAMETER port Port to test .PARAMETER tcp Use tcp port .PARAMETER udp Use udp port .PARAMETER UDP...
PowerShellCorpus/PoshCode/finddupe_9.ps1
finddupe_9.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/ISE-Snippets variant.ps1
ISE-Snippets variant.ps1
#requires -version 2.0 ## ISE-Snippets module v 1.0 ## DEVELOPED FOR CTP3 ## See comments for each function for changes ... ############################################################################################################## ## As a shortcut for every snippet would be to much, I created Add-Snippet whic...
PowerShellCorpus/PoshCode/0220791d-2756-4988-aca9-8cfa1366a66c.ps1
0220791d-2756-4988-aca9-8cfa1366a66c.ps1
param ([string]$recursePath= $(Throw "Du mň spesifisere ei mappe!")) function build-word-docs($recursePath) { # $dir = "C:\\Users\\bjorninge\\Documents\\My Dropbox\\mafo-bjorn\\bachelor-prosjekt\\Driftsdokumentasjon" $oldDir = get-location cd $recursePath $files = ls -Recurse | where {$_.extensio...
PowerShellCorpus/PoshCode/Movable button.ps1
Movable button.ps1
$btnMove_MouseDown= { if ($_.Button -eq [Windows.Forms.MouseButtons]::Left) { $bool = $true $coor = [Drawing.Point]$_.Location } } $btnMove_MouseMove= { if ($bool) { $btnMove.Location = New-Object Drawing.Point( ($btnMove.Left - $btnMove.X + $_.X), ($btnMove.Top - $btnMove.Y + $_.Y) ...
PowerShellCorpus/PoshCode/vSphere Resultant Privs_2.ps1
vSphere Resultant Privs_2.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-Netstat _1.9.ps1
Get-Netstat _1.9.ps1
$null, $null, $null, $null, $netstat = netstat -a -n -o [regex]$regex = '\\s+(?<Protocol>\\S+)\\s+(?<LocalAddress>\\S+)\\s+(?<RemoteAddress>\\S+)\\s+(?<State>\\S+)\\s+(?<PID>\\S+)' $netstat | ForEach-Object { if ( $_ -match $regex ) { $process = "" | Select-Object Protocol, LocalAddress, Rem...
PowerShellCorpus/PoshCode/Start-Cassini.ps1
Start-Cassini.ps1
function Start-Cassini([string]$physical_path=".", [int]$port=12372, [switch]$dontOpenBrowser) { $serverLocation = Resolve-Path "C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\DevServer\\10.0\\WebDev.WebServer40.EXE"; $full_app_path = Resolve-Path $physical_path $url = "http://localhost:$port" &($...
PowerShellCorpus/PoshCode/Get-Command 2.0.ps1
Get-Command 2.0.ps1
## Which.ps1 - aka Get-Command ################################################################################################### ## This ought to be the same as Get-Command, except... ## This Which function will output the commands ... ## in the actual order they would be used by the shell ######################...
PowerShellCorpus/PoshCode/Sendmail for PoSh 2 CTP3.ps1
Sendmail for PoSh 2 CTP3.ps1
#region vars $script:maileditor = "C:\\Programme\\vim\\vim72\\vim.exe" $script:encryption = "C:\\Programme\\GNU\\GnuPG\\gpg.exe" $script:enckey = "s.patrick1982@gmail.com" $script:tempmail = "C:\\temp\\psmail.txt" $script:sigmail = "C:\\temp\\halten\\sig.txt" $script:mailbody = "" #endregion vars #region init...
PowerShellCorpus/PoshCode/Split-Job V 1.2.1.ps1
Split-Job V 1.2.1.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/VMWare Quick Migration_5.ps1
VMWare Quick Migration_5.ps1
######################################### #Name: VMWare Quick Migration Function #Author: Justin Grote <jgrote NOSPAMAT enpointe DOT com> #Credit: Inspired by Mike DiPetrillo's Quick Migration Script: http://www.mikedipetrillo.com/mikedvirtualization/2008/10/quick-migration-for-vmware-the-power-of-powershell.html #...
PowerShellCorpus/PoshCode/New-ODataServiceProxy_3.ps1
New-ODataServiceProxy_3.ps1
function New-ODataServiceProxy { #.Synopsis # Creates a proxy class for an odata web service and assigns it to the specified variable. # DOES NOT output the proxy on the pipleline, and you should not do so either! #.Description # Uses the data service client utility (DataSvcUtil.exe) to generate a proxy class ...
PowerShellCorpus/PoshCode/Send-SmtpMessage.ps1
Send-SmtpMessage.ps1
## Send-SmtpMessage -- a special implementation to show how to send via GMail ## GMail is a bit more complicated than most.... ################################################################################################### ## Examples: ## Send-SmtpMessage "receiver@gmail.com" "Hello there" "This is an important...
PowerShellCorpus/PoshCode/Highlight-Syntax 2.0.ps1
Highlight-Syntax 2.0.ps1
#requires -version 2.0 # Highlight-Syntax.ps1 # version 2.0 # by Jeff Hillman # # this script uses the System.Management.Automation.PsParser class # to highlight PowerShell syntax with HTML. param( [string] $code, [switch] $LineNumbers ) if ( Test-Path $code -ErrorAction SilentlyContinue ) { $code =...
PowerShellCorpus/PoshCode/ConvertFrom-Hashtable_2.ps1
ConvertFrom-Hashtable_2.ps1
# function ConvertFrom-Hashtable { PARAM([HashTable]$hashtable,[switch]$combine) BEGIN { $output = New-Object PSObject } PROCESS { if($_) { $hashtable = $_; if(!$combine) { $output = New-Object PSObject } } $hashtable.GetEnumerator() | ForEach-Object { Add-Member -inputObject $outpu...
PowerShellCorpus/PoshCode/USB Script backup_4.ps1
USB Script backup_4.ps1
<# .SYNOPSIS Backup-ToUSB.ps1 (Version 3.1, 19 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. Any ...
PowerShellCorpus/PoshCode/Get-DefragAnalysis_1.ps1
Get-DefragAnalysis_1.ps1
# defrag_analysis.ps1 # # Displays Defrag Analysis Info for a remote server. # # Author: tojo2000@tojo2000.com Set-PSDebug -Strict` trap [Exception] { continue } function GenerateForm { [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null [reflection.assembly]::loadwithpartialname(...
PowerShellCorpus/PoshCode/d1c44eb5-e148-4345-a712-661f0b8e3e08.ps1
d1c44eb5-e148-4345-a712-661f0b8e3e08.ps1
# # simple example using a hash to parse CAS Connect Logs # # after using the get-CASConnectLogEntries.ps1 to collect the log information # this script runs thru those files and counts Cached vs Classic # # # the directory where you keep these "cas connect logs" - change to fit your needs $Script:CasLogUNC...
PowerShellCorpus/PoshCode/vmware guests subnet.ps1
vmware guests subnet.ps1
$snapins = "vmware.vimautomation.core" foreach ($snapin in $snapins){if (!(Get-PSSnapin $snapin -ErrorAction SilentlyContinue)){Add-PSSnapin $snapin}} $vserver = "vmware vCenter Server" $vNetwork = "General_Services" $logfile = "d:\\Scripts\\log\\vm.log" $subnet = "255.255.255.128" connect-viserver -Server $v...
PowerShellCorpus/PoshCode/SharePoint Site Owners.ps1
SharePoint Site Owners.ps1
Get-SPWebApplication | Get-SPSite -Limit ALL | ForEach-Object { $content = ""; $rootSite = New-Object Microsoft.SharePoint.SPSite($_.Url) $subSites = $rootSite.AllWebs; if($subSites.Count -le 0) { @@ This occurs when a Site Collection does not contains any subsite (not even the root s...
PowerShellCorpus/PoshCode/Script logging.ps1
Script logging.ps1
#region Log File Management $ScriptName = $MyInvocation.mycommand.name $LocalAppDir = "$(gc env:LOCALAPPDATA)\\PS_Data" $LogName = $ScriptName.replace(".ps1", ".log") $MaxLogFileSizeMB = 5 # After a log file reaches this size it will archive the existing and create a new one trap [Exception] { sendl "er...
PowerShellCorpus/PoshCode/Binary Clock_1.ps1
Binary Clock_1.ps1
function get-binary($number,$words=1+(1*[int]($number -gt 255))) { # Takes the passed numerical value and converts to a Binary word. # Pads 0 to the left to make it a proper set of 8 or 16 # # If you use this function outside of the clock, it is automatically # designed to generate a 16 bit output padded if t...
PowerShellCorpus/PoshCode/Get-TwitterReply.ps1
Get-TwitterReply.ps1
# Its a modification from the version in http://blogs.technet.com/jamesone/archive/2009/02/16/how-to-drive-twitter-or-other-web-tools-with-powershell.aspx # usees https and gets all replies Function Get-TwitterReply { param ($username, $password) if ($WebClient -eq $null) {$Global:WebClient=new-object System.N...
PowerShellCorpus/PoshCode/New-ArgsTestExe.ps1
New-ArgsTestExe.ps1
Add-Type -Type @" using System; internal class ArgsTest { private static void Main(string[] args) { Console.WriteLine(); /* I've commented this out because (at least in C#) it is the same as Environment.GetCommandLineArgs() Except that GetCommandLineArgs shows p...
PowerShellCorpus/PoshCode/Out-DataTable.ps1
Out-DataTable.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/ASPX Mailbox (5 of 6).ps1
ASPX Mailbox (5 of 6).ps1
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MailboxTaskResults.aspx.cs" Inherits="MailboxTaskResults" %> <%@ Reference Page="~/MailboxConfirm.aspx" %> <%@ PreviousPageType VirtualPath="~/MailboxConfirm.aspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DT...
PowerShellCorpus/PoshCode/VMware guest information.ps1
VMware guest information.ps1
# vminfo.ps1 # # Give this a VMware guest and it will attempt to dump all the information available. # # Example: .\\vminfo.ps1 "guestname" # # This scripts assumes that you have already connected to a VirtualCenter server. # # This was developed and tested using VMware vSphere PowerCLI version 4.1.1.2816 # o...
PowerShellCorpus/PoshCode/WPFDiskSpace.ps1
WPFDiskSpace.ps1
#Usage: Get-WmiObject -computername Z002 Win32_LogicalDisk -filter "DriveType=3" | ./WPFDiskSpace.ps1 #Note: Requires .NET 3.5, Visifire Charts (tested on v2.1.0), Powerboots (tested on v0.1) $libraryDir = Convert-Path (Resolve-Path "$ProfileDir\\Libraries") [Void][Reflection.Assembly]::LoadFrom( (Convert-Path (Re...
PowerShellCorpus/PoshCode/AD attributes.ps1
AD attributes.ps1
<%@ Language=VBScript %> <% StartTime = Timer %> <!--#include file = "global.inc"--> <html> <head><title><%=strCompany%> - Search List</title> </head> <body> <!--#include file="default.htm"--> <link rel="stylesheet" href="/server/default.css" TYPE="text/css" media="screen"> <% Dim MyVariable MyVariable=Reque...
PowerShellCorpus/PoshCode/SearchZIP_3.psm1 .ps1
SearchZIP_3.psm1 .ps1
function SearchZIPfiles { <# .SYNOPSIS Search for (filename) strings inside compressed ZIP or RAR files (V2.4). .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/Test-TCPPort_2.ps1
Test-TCPPort_2.ps1
function Test-TCPPort { param ( [parameter(Mandatory=$true)] [string] $ComputerName, [parameter(Mandatory=$true)] [string] $Port ) try { $TimeOut = 5000 $IsConnected = $false $Addresses = [System.Net.Dns]::GetHostAddresses($ComputerName) | ? {$_.AddressFamily -eq 'InterNetwork'} $Ad...
PowerShellCorpus/PoshCode/Dumping COM.ps1
Dumping COM.ps1
$arr = @() $key = "HKLM:\\SOFTWARE\\Classes\\CLSID" foreach ($i in (gci $key)) { $des = $key + "\\" + $i.PSChildName + "\\ProgID" Write-Progress "Dumping. Please, standby..." $des foreach ($a in (gp -ea 0 $des)."(default)") { $arr += $a } } [array]::Sort([array]$arr) $arr | Out-File -file C:...
PowerShellCorpus/PoshCode/Get-DiskUsage_4.ps1
Get-DiskUsage_4.ps1
Function Get-DiskUsage { <# .SYNOPSIS A tribute to the excellent Unix command DU. .DESCRIPTION This command will output the full path and the size of any object and it's subobjects. Using just the Get-DiskUsage command without any parameters will result in an output of the directory you are currently p...
PowerShellCorpus/PoshCode/egg_timer_1.ps1
egg_timer_1.ps1
function GenerateForm { [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null $form_main = New-Object System.Windows.Forms.Form $reset_button = New-Object System.Windows.Forms.Button $label1 = New-Object Sys...
PowerShellCorpus/PoshCode/Export-HTML.ps1
Export-HTML.ps1
#Requires -Version 2.0 <# Export-Html behaves exactly like native ConvertTo-HTML However it has one optional parameter -Path Which lets you specify the output file: e.g. Get-Process | Export-Html C:\\temp\\processes.html (c) Dmitry Sotnikov http://dmitrysotnikov.wordpress.com Proxy generated usin...
PowerShellCorpus/PoshCode/337d4ddf-c2e9-4243-8681-ea4303a40040.ps1
337d4ddf-c2e9-4243-8681-ea4303a40040.ps1
None
PowerShellCorpus/PoshCode/Convert-SchemaGUID.ps1
Convert-SchemaGUID.ps1
# List of Guids not properly defined in AD but used # Used to initialize GuidCache. New-Variable -Name GuidCache -Force -Option AllScope -Scope Script -Description "Cached GUIDs from AD. :: [redtoo]" $Script:GuidCache = @{ "a05b8cc2-17bc-4802-a710-e7c15ab866a2" = "Autoenroll" "00000000-0000-0000-0000-00...
PowerShellCorpus/PoshCode/Map a Network Drive.ps1
Map a Network Drive.ps1
function MapNetDrive { param( #Non-Boolean parameters (Values) # [Parameter(Position=0,Mandatory=$true)] [string]$DriveLetter="Z:", [Parameter(Position=1,Mandatory=$true)] [string]$Path, #Boolean switches (On/Off) # [Parameter(Position=2,Mandatory=$false)]...
PowerShellCorpus/PoshCode/Start-BootsTimer_2.ps1
Start-BootsTimer_2.ps1
function Start-BootsTimer { #.Syntax # Creates a stay-on-top countdown timer #.Description # A WPF borderless count-down timer, with audio/voice alarms and visual countdown + colored progress indication #.Parameter EndMessage # The message to be spoken by a voice when the time is up... #.Parameter StartMessag...
PowerShellCorpus/PoshCode/Appscanner v0.10.ps1
Appscanner v0.10.ps1
####################### #Appscanner V0.10 #Author Adam Liquorish #Creation Date 08/11/11 #Change log: # 14/11/11 Removed unrequired step # 02/12/11 Created input choice for domain.local,cached rather than auto determine # 02/12/11 Added all supported filetypes for applockers ".bat",".cmd","....
PowerShellCorpus/PoshCode/divide integer.ps1
divide integer.ps1
function divide-integer ([int]$dividend , [int]$divisor ){ [int]$local:remainder = $Null;return [Math]::DivRem($dividend,$divisor,[ref]$local:remainder);} set-alias i/ divide-integer i/ 10 3 function divide-integerpipe ([int]$divisor ) { begin { [int]$local:remainder = $Null} process { [Math]::DivRem($_ ,$di...
PowerShellCorpus/PoshCode/Get-GPOSettings.ps1
Get-GPOSettings.ps1
<# .SYNOPSIS Get-GPOSettings .DESCRIPTION This script gets a list of all Group Policy Objects in the domain filtered on the value of GPOSettingName. For each GPO if the Extension Name matches GPOSettingName the Extensions are then reported back. .PARAMETER GPOSettingN...
PowerShellCorpus/PoshCode/FTP download.ps1
FTP download.ps1
$File = "D:\\Dev\\somefilename.zip" $ftp = "ftp://username:password@example.com/pub/incoming/somefilename.zip" "ftp url: $ftp" $webclient = New-Object System.Net.WebClient $uri = New-Object System.Uri($ftp) "Uploading $File..." $webclient.UploadFile($uri, $File)
PowerShellCorpus/PoshCode/Get-WebPage_1.ps1
Get-WebPage_1.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/Set-Blur.ps1
Set-Blur.ps1
Add-Type -Type @" using System; using System.Runtime.InteropServices; namespace Huddled { public class Dwm { [DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); [DllImport("user32.dll", SetLastError=true)] public stati...
PowerShellCorpus/PoshCode/Get-WebFile 3.5.ps1
Get-WebFile 3.5.ps1
## Get-WebFile.ps1 (aka wget for PowerShell) ############################################################################################################## ## Downloads a file or page from the web ## History: ## v3.5 - Add -Quiet switch to turn off the progress reports ... ## v3.4 - Add progress report for files w...