full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/d62dc55e-3050-4347-8836-eb27971623ff.ps1
d62dc55e-3050-4347-8836-eb27971623ff.ps1
####### Log deletions in all sites in a web application ###### ############# http://iLoveSharePoint.com ################## ############## by Christian Glessner ###################### ################ begin config ################# # Url of the web application to audit. Don't forget to activate the delete audi...
PowerShellCorpus/PoshCode/get windows product key_2.ps1
get windows product key_2.ps1
function get-windowsproductkey([Parameter(ValueFromPipeline=$true)][string[]]$computer) { PROCESS{ foreach($comp in $computer) { $Reg = [WMIClass] ("\\\\" + $comp + "\\root\\default:StdRegProv") $values = [byte[]]($reg.getbinaryvalue(2147483650,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion","DigitalProductId")....
PowerShellCorpus/PoshCode/VMtoolsUpgrade-disable_1.ps1
VMtoolsUpgrade-disable_1.ps1
##################################################################### # TIAA-CREF VMWare Standard Scripts - PowerCLI # # Purpose: "Check and upgrade Tools during power cycling" # Author: David Chung # Support: IT Infrastructure # Docs: N/A # # Instruction: 1. Create CSV file with list of servers # ...
PowerShellCorpus/PoshCode/Get-ChilditemsRecursive.ps1
Get-ChilditemsRecursive.ps1
function Get-ChildItem2 ($path) { # path can either be absolut or relative, I only tried filesystem # perhaps to named Get-ChildItemsRecursive $root = gi $path $PathLength = $root.FullName.length # it would be nice if Split-Path could do the trick, I didn't grok it gci $path -rec | % { ...
PowerShellCorpus/PoshCode/Script permissions_1.ps1
Script permissions_1.ps1
<# .SYNOPSIS Applies permissions and roles to vSphere vApps .DESCRIPTION Applies permissions and roles to vSphere vApps -VIServer (Optional, defaults to Development) {FQDN of VCentre Server} -AppName (Required) {VApp Label} -ADGroup (Optional) {Domain\\Group_Object} -Role (Optional) {vSphere Role, ReadO...
PowerShellCorpus/PoshCode/disabled AD accounts.ps1
disabled AD accounts.ps1
#Get Domain List $objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() $DomainList = @($objForest.Domains | Select-Object Name) $Domains = $DomainList | foreach {$_.Name} #get users list $users = Get-Content U:\\EMCU15FI3_USER.txt $total = $users.count "SAMaccountname;DisplayName...
PowerShellCorpus/PoshCode/Get-ServiceAccounts_1.ps1
Get-ServiceAccounts_1.ps1
#requires -pssnapin PSCX #Author: Glenn Sizemore glnsize@get-admin.com #Purpose: Scan a remote system for any services running under a non standard account. # Standard accounts would be considered, NT AUTHORITY\\NetworkService, # NT AUTHORITY\\LocalService, LocalSystem, or .\\ASPNET #...
PowerShellCorpus/PoshCode/PowerShell script config.ps1
PowerShell script config.ps1
################################################# # Sample code showing how to save/load PowerShell script # configuration to disk # # (c) Dmitry Sotnikov # http://dmitrysotnikov.wordpress.com/2010/05/07/storing-powergui-add-on-configuration ################################################# # Assign unique fol...
PowerShellCorpus/PoshCode/Get-LocalGroupAllMembers.ps1
Get-LocalGroupAllMembers.ps1
# ############################################################################# # NAME: FUNCTION-Get-LocalGroupAllMembers.ps1 # # AUTHOR: Francois-Xavier Cat # DATE: 2012/12/27 # EMAIL: fxcat@lazywinadmin.com # WEBSITE: LazyWinAdmin.com # TWiTTER: @lazywinadm # # COMMENT: The following functions will ...
PowerShellCorpus/PoshCode/Get Twitter RSS Feed.ps1
Get Twitter RSS Feed.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/New-Zip_2.ps1
New-Zip_2.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/Set-Domain.ps1
Set-Domain.ps1
function Set-Domain { param( [switch]$help, [string]$domain=$(read-host "Please specify the domain to join"), [System.Management.Automation.PSCredential]$credential = $(Get-Credential) ) $usage = "`$cred = get-credential `n" $usage += "Set-AvaDomain -domain corp.avanade.org -credential `$cred`n"...
PowerShellCorpus/PoshCode/Get-SiSReport_1.ps1
Get-SiSReport_1.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/Set-Wallpaper (CTP3)_1.ps1
Set-Wallpaper (CTP3)_1.ps1
#requires -version 2.0 ## Set-Wallpaper - set your windows desktop wallpaper ################################################################################################### ## Usage: ## Set-Wallpaper "C:\\Users\\Joel\\Pictures\\Wallpaper\\Dual Monitor\\mandolux-tiger.jpg" "Tile" ## ls *.jpg | get-random ...
PowerShellCorpus/PoshCode/Split.ps1
Split.ps1
function Split { <# .Synopsis Splits up a file into smaller files. .Description This function takes a file as input and splits it into files by a set number of lines. .Parameter filename The name of the file to be used as an input. This value can be piped to the function (see examples) .Parameter lines The n...
PowerShellCorpus/PoshCode/Highlight-Syntax _3.0.ps1
Highlight-Syntax _3.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/Add-PrinterDriver.ps1
Add-PrinterDriver.ps1
#requires -version 2 function Add-PrinterDriver { <# .SYNOPSIS Adds printer drivers to the local computer from a specified print server. .DESCRIPTION Adds printer drivers to the local computer from a specified print server. The function collects all shared printer objects from the specified print server and inst...
PowerShellCorpus/PoshCode/Find sharable storage_1.ps1
Find sharable storage_1.ps1
# This function returns all datastores that can be shared amongst ESX hosts. function Get-ShareableDatastore { # Get all datastores. $datastores = Get-Datastore # Load the HostStorageSystems of all hosts. $hosts = Get-VMHost | Get-View -property ConfigManager $storageSystems = @() foreach ($h in $hosts) ...
PowerShellCorpus/PoshCode/where-in.ps1
where-in.ps1
function where-in { [cmdletbinding()] param ( [parameter(mandatory = $true,position = 1)] [system.Collections.IEnumerable]$collection, [parameter(position = 2)] [scriptblock]$predicate , [parameter(valuefrompipeline = $true)] $pipelineobject ) process { if ($predicate) { foreach ($__...
PowerShellCorpus/PoshCode/Get-MailboxesOverSizeLim.ps1
Get-MailboxesOverSizeLim.ps1
# ------------------------------------------------------------------------------- # Script: Get-MailboxesOverSizeLimit.ps1 # Author: Chris Brown # Date: 04/04/2011 10:41:00 # Keywords: # comments: # # Versioning # 04/04/2011 CJB Initial Script # # ------------------------------------------------------------...
PowerShellCorpus/PoshCode/Connect-LabManager.ps1
Connect-LabManager.ps1
function Ignore-SslErrors { # Create a compilation environment $Provider=New-Object Microsoft.CSharp.CSharpCodeProvider $Compiler=$Provider.CreateCompiler() $Params=New-Object System.CodeDom.Compiler.CompilerParameters $Params.GenerateExecutable=$False $Params.GenerateInMemory=$True $Params.IncludeDebugIn...
PowerShellCorpus/PoshCode/Edit-File in Notepad++.ps1
Edit-File in Notepad++.ps1
<# .Synopsis Open a file for editing in notepad++ .Description Opens one or more files in Notepad++, passing all the switches each time. Accepts filenames on the pipeline .Notes I took the "no" off the parameters, because in PowerShell you only need to enter just enough of the parameter name to differ...
PowerShellCorpus/PoshCode/LoadModuleConfig_2.ps1
LoadModuleConfig_2.ps1
################################################################################ ## Script Name: LoadModuleConfig ## Created On: 01/21/2010 ## Author: Thell Fowler ## File: LoadModuleConfig.ps1 ## Usage: Called from the NestedModules value from a module manifest. ## Version:...
PowerShellCorpus/PoshCode/Move-Template_1.ps1
Move-Template_1.ps1
Function Move-Template{ <# .Synopsis Move a VM template .Description Move a VM template either to a new host via vmotion or to a new datastore via svmotion .Parameter Name Name of the VM to be migrated .Parameter VIObject Template to be migrated .Paramet...
PowerShellCorpus/PoshCode/Test-TCPPort.ps1
Test-TCPPort.ps1
# http://powershell.codeplex.com Function Test-TCPPort { param ( [ValidateNotNullOrEmpty()] [string] $EndPoint = $(throw "Please specify an EndPoint (Host or IP Address)"), [string] $Port = $(throw "Please specify a Port") ) $TimeOut = 1000 $IP = [System.Net.Dns]::GetHostAddresses($EndPoint) $Address...
PowerShellCorpus/PoshCode/Get-DiskUsage_2.ps1
Get-DiskUsage_2.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/Run-Query (SharePoint).ps1
Run-Query (SharePoint).ps1
function Run-Query($siteUrl, $queryText) { [reflection.assembly]::loadwithpartialname("microsoft.sharePOint") | out-null [reflection.assembly]::loadwithpartialname("microsoft.office.server") | out-null [reflection.assembly]::loadwithpartialname("microsoft.office.server.search") | out-null $s = [microsoft.share...
PowerShellCorpus/PoshCode/Script-Object_3.ps1
Script-Object_3.ps1
#Copyright (c) 2011 Justin Dearing # #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, modify, merge, publish, dist...
PowerShellCorpus/PoshCode/Get-InstalledProgram_v_3.ps1
Get-InstalledProgram_v_3.ps1
function Get-InstalledProgram() { param ( [String[]]$Computer, $User ) ############################################################################################# if ($User) {$Connection = Get-Credential -Credential $User} ########################################################################################...
PowerShellCorpus/PoshCode/Set Active Sync DevideID.ps1
Set Active Sync DevideID.ps1
# Requires a connection to Exchange Server, or Exchange Management Shell $s = New-PSSession -ConfigurationName Microsoft.Exchange -Name ExchMgmt -ConnectionUri http://ex14.domain.local/PowerShell/ -Authentication Kerberos Import-PSSession $s # Get all Client Access Server properties for all mailboxes with an Act...
PowerShellCorpus/PoshCode/Ping Alert Script_1.ps1
Ping Alert Script_1.ps1
#Email Alert Parameters $to = "user@mydomain.com" $from = "unreachable@mydomain.com" $smtpserver = "my_exchange_server" #Array of computers to test $Computers = ("comp1" , "comp2" , "comp3" , "comp4") #Variable to hold INT value 0 $zero = 0 Foreach ($Computer in $Computers) { if...
PowerShellCorpus/PoshCode/Show-Fonts.ps1
Show-Fonts.ps1
ipmo PowerBoots # Require PowerBoots ## More readable: New-BootsWindow { ScrollViewer { StackPanel { ForEach($font in (New-Object Drawing.Text.InstalledFontCollection).Families | Select -Expand Name) { TextBlock "$font -- The brown fox (quickly) jumps over the ""lazy"" dog, 1234...
PowerShellCorpus/PoshCode/New-Zip_4.ps1
New-Zip_4.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/Wizard template.ps1
Wizard template.ps1
####################################################################################################################### # File: wizard_template.ps1 # # Author: Alexander Petrovskiy ...
PowerShellCorpus/PoshCode/PS2WCF_4.ps1
PS2WCF_4.ps1
<# .SYNOPSIS Functions to call WCF Services With PowerShell. .NOTES Version 1.1 10.02.2012 Requires Powershell v2 and .NET 3.5 Original version by Christian Glessner Blog: http://www.iLoveSharePoint.com Twitter: http://twitter.com/cglessner Codeplex: http://codeplex.com/iLoveSharePoint PowerS...
PowerShellCorpus/PoshCode/SharpSsh Functions_3.ps1
SharpSsh Functions_3.ps1
## USING the binaries from: ## http://downloads.sourceforge.net/sharpssh/SharpSSH-1.1.1.13.bin.zip [void][reflection.assembly]::LoadFrom( (Resolve-Path "~\\Documents\\WindowsPowerShell\\Libraries\\Tamir.SharpSSH.dll") ) ## NOTE: These are bare minimum functions, and only cover ssh, not scp or sftp ## also, ...
PowerShellCorpus/PoshCode/Get-Netstat 0.9.ps1
Get-Netstat 0.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, Remo...
PowerShellCorpus/PoshCode/2ee1612d-7a4e-467a-8ae1-8c310bb1cba0.ps1
2ee1612d-7a4e-467a-8ae1-8c310bb1cba0.ps1
#Purpose: To remotely query select machines for system information #Author: Alex Smith #Created: 6/11/2010 #Arguments: IP Addresses or Hostnames of target PCs then path and file name #Examples: To query based on hostname or ip: C:\\>powershell .\\WMIQuery.ps1 host1 # To print to a file: C:\\>po...
PowerShellCorpus/PoshCode/Upgrade Templates to v7.ps1
Upgrade Templates to v7.ps1
Function Convert-TemplateToVM($template){ Write-Host "Converting" $vm -ForegroundColor Yellow Set-Template $template -ToVM -RunAsync | out-null } Function PowerOn-VM($vm){ Start-VM -VM $vm -Confirm:$false -RunAsync do { $vmview = get-VM $vm | Get-View $status = $vmview.Guest.ToolsStatus...
PowerShellCorpus/PoshCode/Close by window title.ps1
Close by window title.ps1
using System; using System.Text; using System.Drawing; using System.Reflection; using System.Diagnostics; using System.Windows.Forms; using System.ComponentModel; using System.Runtime.InteropServices; [assembly: AssemblyTitle("CloseByTitle")] [assembly: AssemblyVersion("3.5.0.0")] namespace CloseByTitle {...
PowerShellCorpus/PoshCode/Get-Exchange-Mail.ps1
Get-Exchange-Mail.ps1
[Reflection.Assembly]::LoadFile("C:\\Program Files\\Microsoft\\Exchange\\Web Services\\1.1\\Microsoft.Exchange.WebServices.dll") | Out-Null $s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1) $s.Credentials = New-Object Net.Netwo...
PowerShellCorpus/PoshCode/Find Local Group Members_10.ps1
Find Local Group Members_10.ps1
# Author: Hal Rottenberg # Purpose: Find matching members in a local group # Used tip from RichS here: http://powershellcommunity.org/Forums/tabid/54/view/topic/postid/1528/Default.aspx # Change these two to suit your needs $ChildGroups = "Domain Admins", "Group Two" $LocalGroup = "Administrators" $MemberName...
PowerShellCorpus/PoshCode/FTP upload_3.ps1
FTP upload_3.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/Save-Credentials_2.ps1
Save-Credentials_2.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/GPRS Online log_8.ps1
GPRS Online log_8.ps1
<# .SYNOPSIS Get-GprsTime (V4.0 Update for Windows 7 and allow time correction) (V4.2 'Interval' now incorporate previous 'FormatSpan' function) Check the total connect time of any GPRS SIM devices from a specified date. Use 'Get-Help .\\Get-GprsTime -full' to view Help for this script. .DESCRIPTION...
PowerShellCorpus/PoshCode/Run-Query (SharePoint)_3.ps1
Run-Query (SharePoint)_3.ps1
function Run-Query($siteUrl, $queryText) { [reflection.assembly]::loadwithpartialname("microsoft.sharePOint") | out-null [reflection.assembly]::loadwithpartialname("microsoft.office.server") | out-null [reflection.assembly]::loadwithpartialname("microsoft.office.server.search") | out-null $s = [microsoft.share...
PowerShellCorpus/PoshCode/PowerShell CMatrix_1.ps1
PowerShell CMatrix_1.ps1
Set-StrictMode -off # # Module: PowerShell Console ScreenSaver Version 0.1 # Author: Oisin Grehan ( http://www.nivot.org ) # # A PowerShell CMatrix-style screen saver for true-console hosts. # # This will not work in Micrisoft's ISE, Quest's PowerGUI or other graphical hosts. # It should work fine in PowerShe...
PowerShellCorpus/PoshCode/app memory deltas.ps1
app memory deltas.ps1
## Use ps to measure Application Memory Deltas ## Run '.\\ws_diff [Interval in Seconds] [Process Name] or ## to log all processes continually every 10 seconds -- 'while (1) {.\\WS_diff.ps1 10 cmd >> ps_out.txt }' # Create args as Variables or Objects $sleep_time = $args[0] #$sleep_time = 10 # Create or defin...
PowerShellCorpus/PoshCode/Upgrade-VMToolsNoReboot.ps1
Upgrade-VMToolsNoReboot.ps1
#======================================================================== # Created on: 7/11/2012 3:59 PM # Created by: Clint Jones # Organization: Virtually Genius! # Filename: Upgrade-VMToolsNoReboot #======================================================================== Add-PSSnapin VMware.VimAutom...
PowerShellCorpus/PoshCode/Xml Module 6.1.ps1
Xml Module 6.1.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-Parameter 2.6.ps1
Get-Parameter 2.6.ps1
#Requires -version 2.0 #.Synopsis # Enumerates the parameters of one or more commands #.Notes # With many thanks to Hal Rottenberg, Oisin Grehan and Shay Levy # Version 0.80 - April 2008 - By Hal Rottenberg http://poshcode.org/186 # Version 0.81 - May 2008 - By Hal Rottenberg http://poshcode.org/255 # Ver...
PowerShellCorpus/PoshCode/Get-InstalledSoftware.ps.ps1
Get-InstalledSoftware.ps.ps1
##############################################################################\n##\n## Get-InstalledSoftware\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\nLi...
PowerShellCorpus/PoshCode/Run-Defrag.ps1
Run-Defrag.ps1
# Run-Defrag # Defragments the targeted hard drives. # # Args: # $server: A target Server 2003 or 2008 system # $drive: An optional drive letter. If this is blank then all # drives are defragmented # $force: If this switch is set then a defrag will be forced # even if the drive is lo...
PowerShellCorpus/PoshCode/New-ElevatedTask.ps1
New-ElevatedTask.ps1
#requires -version 2.0 #################################################################################################### ## Version History ## 2.0 - First version with shortcut support ## - Still weak on documentation of the arguments, sorry ... ## 2.5 - Improved defaults and documentation (run with -?) ##...
PowerShellCorpus/PoshCode/Find Local Group Members_9.ps1
Find Local Group Members_9.ps1
# Author: Hal Rottenberg # Purpose: Find matching members in a local group # Used tip from RichS here: http://powershellcommunity.org/Forums/tabid/54/view/topic/postid/1528/Default.aspx # Change these two to suit your needs $ChildGroups = "Domain Admins", "Group Two" $LocalGroup = "Administrators" $MemberName...
PowerShellCorpus/PoshCode/Test-UserCredential_1.ps1
Test-UserCredential_1.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/Start-BootsTimer_3.ps1
Start-BootsTimer_3.ps1
Add-BootsFunction -Type "System.Windows.Threading.DispatcherTimer" 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 t...
PowerShellCorpus/PoshCode/chkhash_14.ps1
chkhash_14.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/Snapshot VM in a folder.ps1
Snapshot VM in a folder.ps1
#Revision 1 #7-29-2008 #author Jon Owings #contact - jowings at securas dot com # #Create a snapshot of all the vm's in a folder, #be sure to change to match your enviroment. use at your own risk, snapshots have been known to #cause certain configurations to lock (freeze) so test in a dev enviroment first. #...
PowerShellCorpus/PoshCode/Set-LocalPassword.ps1
Set-LocalPassword.ps1
# Sets local account passwords on one or more computers # usage [computerName1,computerName2,... | ] ./Set-LocalPassword.ps1 [-user] <userName> [-password] <password> [[-computers] computerName1,computerName2,...] param( [string] $User , [string] $Password , [string[]] $ComputerNames = @() ) $ComputerN...
PowerShellCorpus/PoshCode/SVMotion-VM_2.ps1
SVMotion-VM_2.ps1
# author: Hal Rottenberg # Website/OpenID: http://halr9000.com # purpose: does "real" SVMotion of a VM # usage: get-vm | SVMotion-VM -destination (get-datastore foo) function SVMotion-VM { param( [VMware.VimAutomation.Client20.DatastoreImpl]$destination ) Begin { $datastoreView = Get-View -VIObject $d...
PowerShellCorpus/PoshCode/Monitor-FileSize_1.ps1
Monitor-FileSize_1.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/ConvertFrom-FahrenheitWi.ps1
ConvertFrom-FahrenheitWi.ps1
## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n\nparam([double] $Fahrenheit)\n\nSet-StrictMode -Version Latest\n\n## Convert Fahrenheit to Celsius\nfunction ConvertFahrenheitToCelsius([double] $fahrenheit)\n{\n $celsius = $fahrenheit - 32\n $celsius = $celsius /...
PowerShellCorpus/PoshCode/Get-PDC09Videos_2.ps1
Get-PDC09Videos_2.ps1
#requires -version 2.0 PARAM ( [Parameter(Position=1, Mandatory=$true)] [ValidateSet("wmv","wmvhigh","ppt")] # the "mp4" files aren't there yet [String]$MediaType, [string]$Destination = $PWD ) if( ([System.Environment]::OSVersion.Version.Major -gt 5) -and -not ( # Vista and ... new-object Secur...
PowerShellCorpus/PoshCode/Read-Choice_3.ps1
Read-Choice_3.ps1
# function Read-Choice { #.Synopsis # Prompt the user for a choice, and return the (0-based) index of the selected item #.Parameter Message # This is the prompt that will be presented to the user. Basically, the question you're asking. #.Parameter Choices # An array of strings representing the choices (or me...
PowerShellCorpus/PoshCode/Hardware Inventory.ps1
Hardware Inventory.ps1
# Synopsis: # Windows Script to collect Hardware information on a local system # And Convert it to a JSON String and Upload that to a CouchDB # Database # Requirements: # -Local Admin Access in Powershell v2 # -SSL(443/TCP) allowed to CouchDB Host # -Proxy verified and communication to it Write-Host " ...
PowerShellCorpus/PoshCode/ConvertTo-CliXml_1.ps1
ConvertTo-CliXml_1.ps1
function ConvertTo-CliXml { param( [parameter(position=0,mandatory=$true,valuefrompipeline=$true)] [validatenotnull()] [psobject]$object ) begin { $type = [type]::gettype("System.Management.Automation.Serializer") $ctor = $type.getconstructor("instance,nonpubl...
PowerShellCorpus/PoshCode/Add new smtp_set prmary.ps1
Add new smtp_set prmary.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/Hack ESXi_2.ps1
Hack ESXi_2.ps1
$screen = " You see here a virtual switch. ------------ ------ #...........| |....| --------------- ###------------ |...(| |..%...........|########## ###-@...| ...
PowerShellCorpus/PoshCode/Get-RemoteRegistry.ps1
Get-RemoteRegistry.ps1
# Get-RemoteRegistry # NOTE: you have to have access, and the remote registry service has to be running param( [string]$computer = $(Read-Host "Remote Computer Name") ,[string]$Path = $(Read-Host "Remote Registry Path (must start with HKLM,HKCU,etc)") ,[switch]$Verbose ) if ($Verbose) { $VerbosePrefere...
PowerShellCorpus/PoshCode/Highlight syntax_1.ps1
Highlight syntax_1.ps1
#code which need highlight $code = @' #just example Get-Process | % { try { "{0, 7} {1}" -f $_.Id, $_.MainModule.ModuleName } catch [System.ComponentModel.Win32Exception] {} } '@ function frmMain_Show { Add-Type -AssemblyName System.Windows.Forms #keywords $type = New-Object "Collection...
PowerShellCorpus/PoshCode/vibackup-lx_1.ps1
vibackup-lx_1.ps1
Param ( $viServer, $bakVM, $lxDest ) #region check if (!$viServer) { $viServer = Read-Host -Prompt "VI Server " } if (!$bakVM) { $bakVM = Read-Host -Prompt "VM to Backup " } if (!$lxDest) { $lxDest = Read-Host -Prompt "Backup Path (ex. /srv/backup) " } #endregion #region globalvars $encoding = "OEM" ...
PowerShellCorpus/PoshCode/Compare-AD.ps1
Compare-AD.ps1
############################################################################### # Compare-AD - a set of functions (and sample code using them) to create # snapshots of user accounts in the current Active Directory domain # save them in an xml file, and then compare live AD environment # against that XML # # (C) ...
PowerShellCorpus/PoshCode/SuperMario PowerShell.ps1
SuperMario PowerShell.ps1
[System.Console]::Beep(659, 125) [System.Console]::Beep(659, 125) Start-Sleep -Milliseconds 125 [System.Console]::Beep(659, 125) Start-Sleep -Milliseconds 167 [System.Console]::Beep(523, 125) [System.Console]::Beep(659, 125) Start-Sleep -Milliseconds 125 [System.Console]::Beep(784, 125) Start-Sleep -Millisecon...
PowerShellCorpus/PoshCode/Send-MailMessage_1.ps1
Send-MailMessage_1.ps1
############################################################################## ## ## Send-MailMessage ## ## From Windows PowerShell Cookbook (O'Reilly) ## by Lee Holmes (http://www.leeholmes.com/guide) ## ## Illustrate the techniques used to send an email in PowerShell. ## In version two, use the Send-MailMessa...
PowerShellCorpus/PoshCode/ISE-Lines_3.ps1
ISE-Lines_3.ps1
#requires -version 2.0 ## ISE-Lines module v 1.1 ## DEVELOPED FOR CTP3 ## See comments for each function for changes ... ############################################################################################################## ## Provides Line cmdlets for working with ISE ## Duplicate-Line - Duplicates curr...
PowerShellCorpus/PoshCode/ShowUI Clock 6.ps1
ShowUI Clock 6.ps1
New-UIWidget -AsJob -Content { $shadow = DropShadowEffect -Color Black -Shadow 0 -Blur 8 $now = Get-Date; StackPanel { TextBlock -Name "Time" ('{0:h:mm tt}' -f $now) -FontSize 108 -LineHeight 100 -LineStackingStrategy BlockLineHeight -Margin 0 -Padding 0 -Foreground White -Effect $shadow -FontFa...
PowerShellCorpus/PoshCode/GPRS Online log_5.ps1
GPRS Online log_5.ps1
<# .SYNOPSIS Get-GprsTime (V3.3 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/LetterDiamondOneliner v_3.ps1
LetterDiamondOneliner v_3.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 # trimmed 130 chars w/o arg &{param([char]$c)$p=$c-($s=65);$r=,(' '*$p+[char]$s);do{$r+="{0,$p} {1}{0}"-f([char]++$s),(' '*$f++)}until(!--$p);$r;$r[-2..-99]}J # trimmed to...
PowerShellCorpus/PoshCode/ConvertFrom-Property_2.ps1
ConvertFrom-Property_2.ps1
<# .SYNOPSIS Converts data from flat or single-level property files into PSObjects .DESCRIPTION Converts delimited string data into objects .PARAMETER InputObject The text to be parsed .PARAMETER FilePath A file containing text to be parsed (so you can pipeline files to be processed) .PARAMETER Val...
PowerShellCorpus/PoshCode/adv2.ps1
adv2.ps1
#-------------------------------------------------------- # Script : Advanced2_2011.ps1 # Author : marc carter (marcadamcarter) # Date : 4/5/2011 # Keywords: PowerShell, Scripting Games # Comments: # Expected Arguments: ADquery, Excel, textfile, <device_name_or_ip> # Examples: .\\Advanced2_2011.ps1...
PowerShellCorpus/PoshCode/Find Permissions.ps1
Find Permissions.ps1
function findPermission ([string]$a, [string]$b) { $string = $a $user = $b $initialArray = @{} $lowerArray = @{} do{ $initialArray = get-acl $string | %{$_.access} | %{$_.IdentityReference} $lowerArray = $initialArray | %{$_.value.toLower()} | %{$_.SubString(12)} foreach($item in $lowerArray) { if($item.Cont...
PowerShellCorpus/PoshCode/Set-PowerGUIWelcomePage_2.ps1
Set-PowerGUIWelcomePage_2.ps1
######################################################## # Modifies the default PowerGUI admin console # welcome screen to the mht file you supply # Details available at: # http://dmitrysotnikov.wordpress.com/2009/02/11/rebranding-powergui-consolerebranding-powergui-console/ ######################################...
PowerShellCorpus/PoshCode/Get-MountPointInfo.ps1
Get-MountPointInfo.ps1
function Get-MountPointInfo { <# .Synopsis Get mount point volume free space information .Parameter Name Name of the system to query .Parameter Credential The Credentals to use when adding the system .Example Get-MountPointInfo -Name "Server1","Server2" -Cred...
PowerShellCorpus/PoshCode/Export-PSCredential.ps1
Export-PSCredential.ps1
# Author: Hal Rottenberg <hal@halr9000.com> # Url: http://halr9000.com/article/tag/lib-authentication.ps1 # Purpose: These functions allow one to easily save network credentials to disk in a relatively # secure manner. The resulting on-disk credential file can only [1] be decrypted # by the same user account...
PowerShellCorpus/PoshCode/Get-VariableType.ps1
Get-VariableType.ps1
function Get-VariableType { param([string]$Name) get-variable $name | select -expand attributes | ? { $_.gettype().name -eq "ArgumentTypeConverterAttribute" } | % { $_.gettype().invokemember("_convertTypes", "NonPublic,Instance,GetField", $null, $_, @()) } }
PowerShellCorpus/PoshCode/Manage ASP.NET Providers.ps1
Manage ASP.NET Providers.ps1
# Manage_ASP_NET_Providers.ps1 # by Chistian Glessner # http://iLoveSharePoint.com [void][System.Reflection.Assembly]::LoadWithPartialName("System.Web") # posh 2.0: Add-Type -Assembly "System.Web" function global:Set-AppConfigPath($path=$(throw "-path is mandatory")) { [System.AppDomain]::CurrentDomain.Se...
PowerShellCorpus/PoshCode/Get User for Svc_Tasks.ps1
Get User for Svc_Tasks.ps1
#========================================================================== # NAME: GetServiceAndTaskAccounts.ps1 # # AUTHOR: Stephen Wheet # Version: 2.0 # Date: 7/21/10 # # COMMENT: # This script was created to find out which any which services on any of # the servers are running as domain accounts. It ...
PowerShellCorpus/PoshCode/Exchange Mailbox report.ps1
Exchange Mailbox report.ps1
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) { $mailer = new-object Net.Mail.SMTPclient($smtpserver) $msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body) $msg.IsBodyHTML = $true $mailer.send($msg) } Function Get-CustomHTML ($Header){ $Report = @" <!DOCTYPE HTML PUBLIC "-//W...
PowerShellCorpus/PoshCode/Get-Parameter _1.5.ps1
Get-Parameter _1.5.ps1
#Requires -version 2.0 #.Synopsis # Enumerates the parameters of one or more commands #.Notes # With many thanks to Hal Rottenberg, Oisin Grehan and Shay Levy # Version 0.80 - April 2008 - By Hal Rottenberg http://poshcode.org/186 # Version 0.81 - May 2008 - By Hal Rottenberg http://poshcode.org/255 # Ver...
PowerShellCorpus/PoshCode/HelpModules 2.0.ps1
HelpModules 2.0.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/Seach-LocalGroupMemberDo.ps1
Seach-LocalGroupMemberDo.ps1
function Seach-LocalGroupMemberDomenNetwork() { param( $Domen, $User ) function Ping ($Name){ $ping = new-object System.Net.NetworkInformation.Ping if ($ping.send($Name).Status -eq "Success") {$True} else {$False} trap {Write-Verbose "&#1054;&#1096;&#1080;&#1073;&#1082;&#1072; &#1087;&#1080;&#...
PowerShellCorpus/PoshCode/JSON 1.3.ps1
JSON 1.3.ps1
#requires -version 2.0\n# Version History:\n# v 0.5 - First Public version\n# v 1.0 - Made ConvertFrom-Json work with arbitrary JSON \n# - switched to xsl style sheets for ConvertTo-JSON\n# v 1.1 - Changed ConvertFrom-Json to handle single item results\n# v 1.2 - CodeSigned to make a fellow geek happy\n# v 1.3 - ...
PowerShellCorpus/PoshCode/Get-DLRestriction.ps1
Get-DLRestriction.ps1
########################################### # Get-DLRestriction # # Uses QAD cmdlets to retrieve distribution list restriction attributes # and then provides a list of users which can send email messages to the group. # # Usage: Get-DLRestriction "Worldwide Everyone" # # Dmitry Sotnikov, http://dmitrysotnikov....
PowerShellCorpus/PoshCode/Set-IPAddress_3.ps1
Set-IPAddress_3.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/finddupe_19.ps1
finddupe_19.ps1
# new version has more error handling, "-delete" and "-noprompt" and "-recurse" options. function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider]; $hashAlgorithm = new...
PowerShellCorpus/PoshCode/WhileTimeout.ps1
WhileTimeout.ps1
function WhileTimeout ( [int]$interval, [int]$maxTries, [scriptblock]$condition ) { $i = 0 $startTime = Get-Date while ( &$condition ) { $i++ if ( $i -lt $maxTries ) { Start-Sleep -seconds $interval } else { Throw "Operation exceeded timeout" } } $endTime = Get-Date $duration = ( $endTi...
PowerShellCorpus/PoshCode/Set-WinSchedule_2.ps1
Set-WinSchedule_2.ps1
# Set-WinSchedule # Written by Tome Tanasovski # http://powertoe.wordpress.com # version 1.0 # Created March 2010 # # Please read through the synopsis->Description to see the list of features that I hope to get # in a final release. If you choose to work on any of the issues by all means, but please contact #...
PowerShellCorpus/PoshCode/Set-TopMost_2.ps1
Set-TopMost_2.ps1
#Requires -Version 2.0 $signature = @" [DllImport("user32.dll")] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); public static IntPtr FindWindow(string windowName){ return FindWindow(null,windowName); } [DllImport("user32.dll")] public static extern bool Se...
PowerShellCorpus/PoshCode/Amazon AWS user data.ps1
Amazon AWS user data.ps1
<powershell> $ComputerName = $env:COMPUTERNAME $user = [adsi]"WinNT://$ComputerName/Administrator,user" $user.setpassword("Password") </powershell>