full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Get-VMHostSerialNumber.ps1
Get-VMHostSerialNumber.ps1
function Get-VMHostSerialNumber { param([VMware.VimAutomation.Types.VMHost[]]$InputObject = $null) process { $hView = $_ | Get-View -Property Hardware $serviceTag = $hView.Hardware.SystemInfo.OtherIdentifyingInfo | where {$_.IdentifierType.Key -eq "ServiceTag" } $assetTag = $hView.Hardware.SystemInfo.O...
PowerShellCorpus/PoshCode/FTP ListDirectory.ps1
FTP ListDirectory.ps1
$cred = Get-Credential [System.Net.FtpWebRequest]$request = [System.Net.WebRequest]::Create("ftp://joelbennett.net") $request.Method = [System.Net.WebRequestMethods+FTP]::ListDirectory #Details $request.Credentials = $cred $response = $request.GetResponse() $list = Receive-Stream $response.GetResponseStream(...
PowerShellCorpus/PoshCode/Get-Parameter_6.ps1
Get-Parameter_6.ps1
function Get-Parameter ( $Cmdlet, [switch]$ShowCommon ) { foreach ($paramset in (Get-Command $Cmdlet).ParameterSets){ $Output = @() foreach ($param in $paramset.Parameters) { if ( !$ShowCommon ) { if ($param.aliases -match "vb|db|ea|wa|ev|wv|ov|ob|wi|cf") { continue } } $process = "" | Select-O...
PowerShellCorpus/PoshCode/PrinterActivity.ps1
PrinterActivity.ps1
#PrinterChecking Script By Henrik Pedersen Ċmark and Daniel Lundgren #This script is designed to check what printers that is still in use. #It's assumed the printer is classed as inactive if it hasnt been used in X months #The script is reading the Systemlog on a printserver of your choice, the one you type in the...
PowerShellCorpus/PoshCode/Report movie lib. stats.ps1
Report movie lib. stats.ps1
function getmoviestat ($drives) { $drives=$drives | %{if ($_.systemname -eq $env:computername) {add-member -inputobject $_ -name BRs -membertype noteproperty -value ( gci -ea 0 "$($_.name)\\media\\BR movies\\*" -include *.mkv,*.m2ts ) -passthru } else {add-member -inputobject $_ -name BRs -membertype noteproperty ...
PowerShellCorpus/PoshCode/Get-PerformanceHistory _1.ps1
Get-PerformanceHistory _1.ps1
#requires -version 2.0 ## Get-PerformanceHistory.ps1 ############################################################################################################## ## Lets you see the amount of time recent commands in your history have taken ## History: ## v2.5 - added "average" calculation if the first thing in y...
PowerShellCorpus/PoshCode/Select-CSVString_1.ps1
Select-CSVString_1.ps1
# NAME # Select-CSVString # # SYNOPSIS # Convert CSV files to custom objects with properties # # SYNTAX # Select-CSVString -pattern <string[]> -files (ls *) [-StartDate <DateTime>] [-EndDate <DateTime>] param ([regex]$pattern,$files=("$($exinstall)TransportRoles\\Logs\\AgentLog","$($exinstall.substring(...
PowerShellCorpus/PoshCode/finddupe_2.ps1
finddupe_2.ps1
write-host "Usage: finddupe.ps1 <directory1> <directory2> ... <directoryN>" function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider]; $hashAlgorithm = new-object $cr...
PowerShellCorpus/PoshCode/Check Modules path_1..ps1
Check Modules path_1..ps1
function Update-ModulePath { <# .Synopsis Command insures that path and the name of psm1 file are alike. .Description This function should help to troubleshoot modules. It loooks up path that should contain modules. For each .psm1 file found it checks if parent folder containing th...
PowerShellCorpus/PoshCode/Get-ScriptPerformancePro.ps1
Get-ScriptPerformancePro.ps1
#############################################################################\n##\n## Get-ScriptPerformanceProfile\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS...
PowerShellCorpus/PoshCode/PasswordNeverExpires.ps1
PasswordNeverExpires.ps1
# Synopsis: # Windows Script to collect usernames and OU locations # for User Account with Password Set to Never Expire # and email .txt list to email address # Author: VulcanX # Date: 2011/10/11 # Version: 1.0 # Requirements: # -Quest PSSnapin Installed Locally # -SMTP Access to Relay/Exchange # Import...
PowerShellCorpus/PoshCode/Bytes.ps1
Bytes.ps1
#requires -version 2.0\nAdd-Type @"\npublic class Shift {\n public static int Right(int x, int count) { return x >> count; }\n public static uint Right(uint x, int count) { return x >> count; }\n public static long Right(long x, int count) { return x >> count; }\n public static ulong Right(ulong x, int ...
PowerShellCorpus/PoshCode/Get-ExchangeDBSizes_2.ps1
Get-ExchangeDBSizes_2.ps1
<# .SYNOPSIS Get-ExchangeDBSizes - Gather data on Exchange 2007 / 2010 Mailbox Databases. .DESCRIPTION Gathers data from Exchange mailbox servers. These data include: Server\\StorageGroup\\Database (2007) or Database (2010), Total Size (in GB) of the disk, Size of the .edb file (in GB), ...
PowerShellCorpus/PoshCode/Get-SPListItem.ps1
Get-SPListItem.ps1
#.Example # Get-SPListItem "Scrum Team Assignments" # Gets all the items in the list with the default columns on them #.Example # Get-SPListItem -Name "Scrum Team Assignments" -Property "Scrum Team","Team Role","Last","First" # Gets all the items in the list with just the specified columns as properties #.Ex...
PowerShellCorpus/PoshCode/Read-Choice.ps1
Read-Choice.ps1
function Read-Choice { #.Synopsis # Prompt the user for a choice, and return the (0-based) index of the selected item #.Parameter Message # The question to ask #.Parameter Choices # An array of strings representing the "menu" items, with optional ampersands (&) in them to mark (unique) characters to be used to...
PowerShellCorpus/PoshCode/Update-ISETabs.ps1
Update-ISETabs.ps1
foreach($tab in $psISE.PowerShellTabs) { foreach($file in $tab.Files) { $position = Select-Object -InputObject $file.Editor -Property CaretLine, CaretColumn $content = Get-Content $file.FullPath -Raw if($content -ne $file.Editor.Text) { $file.Editor.Text = Get-Content $file.FullPath -...
PowerShellCorpus/PoshCode/Kill-Process_v2.ps1
Kill-Process_v2.ps1
function Kill-Process(){ param( [string[]]$ComputerNames, [string[]]$ProcessNames, $User ) if ($ProcessNames -eq $null){Write-Error 'The parametre "ProcessNames" cannot be empty';break} if ($User -is [String]){$Connection = Get-Credential -Credential $User} if ($Connection -eq $null){ foreach ($int1 ...
PowerShellCorpus/PoshCode/BridgeBot 1.2.ps1
BridgeBot 1.2.ps1
## Depends on the PoshXmpp.dll from http://CodePlex.com/PoshXmpp #requires -pssnapin PoshXmpp ########################################################################################## # @Author: Joel Bennnett # @Usage: # Start-JabberMirror.ps1 User@JabberServer.com Password "groupchat@oneserver.com" "groupchat@an...
PowerShellCorpus/PoshCode/Users_Contacts from CSV_2.ps1
Users_Contacts from CSV_2.ps1
#=============================================================================# #=============================================================================# #=============================================================================# # # SCRIPT : CreateOrUpdateUsersOrContacts.ps1 # LAST UPDATE : 9/18/2009...
PowerShellCorpus/PoshCode/2200e57e-b53f-4e8d-96c9-43d4360ace3e.ps1
2200e57e-b53f-4e8d-96c9-43d4360ace3e.ps1
# Environment proprties [string]$QTDIR = "C:\\Qt\\4.8.3-msvc2008" [string]$rootDir = "C:\\Build\\" [string]$buildDir = "C:\\Build\\build_dir\\" [string]$outputDir = "C:\\Build\\output_dir\\" [string]$svnDir = "C:\\Build\\build_dir\\vacuum" [string]$svnUrl = "http://vacuum-im.googlecode.com/svn/trunk/" [string]...
PowerShellCorpus/PoshCode/Set-IPConfigv4.ps1
Set-IPConfigv4.ps1
# script parameters param( [string[]] $Computers = $env:computername, [switch] $ChangeSettings, [switch] $EnableDHCP, [switch] $IpRelease ) # script variables $nl = [Environment]::NewLine $Domain = "domain.local" $DNSSuffix = @("domain.local,domain.com") $DNSServers = @("10.10.0.1", "10.10.0.2", "10.10.0.3...
PowerShellCorpus/PoshCode/Set-Encoding.ps1
Set-Encoding.ps1
function Set-Encoding{ <# .Synopsis Takes a Script file or any other text file into memory and Re-Encodes it in the format specified. .Parameter FilePath The path to the file to be re-encoded. .Parameter Unicode Outputs the file in Unicode format. .Parameter UTF7 Outputs the file in UTF7 format....
PowerShellCorpus/PoshCode/finddupe_15.ps1
finddupe_15.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/Get-ProcedureCallTree.ps1
Get-ProcedureCallTree.ps1
#requires -version 2 #Uses SQLParser.ps1 script http://poshcode.org/1445 to return Stored Procedure Call Tree #Chad Miller #http://chadwickmiller.spaces.live.com/ param ($procedure, $server, $database, $schema='dbo') add-type -AssemblyName Microsoft.SqlServer.Smo #Only create the dynamic SQLParser type if...
PowerShellCorpus/PoshCode/Get-NestedGroups v_2.ps1
Get-NestedGroups v_2.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/Test if file is writable.ps1
Test if file is writable.ps1
function get-IsWritable(){ <# .Synopsis Command tests if a file is present and writable. .Description Command to test if a file is writeable. Returns true if file can be opened for write access. .Example get-IsWritable -path $foo Test if file $foo is accesible for write acc...
PowerShellCorpus/PoshCode/Get-UserLogonLogoffScrip.ps1
Get-UserLogonLogoffScrip.ps1
##############################################################################\n##\n## Get-UserLogonLogoffScript\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...
PowerShellCorpus/PoshCode/Get-2011SGScriptingScore.ps1
Get-2011SGScriptingScore.ps1
Function Get-2011SGScriptingScore ([Parameter(Mandatory=$True)][STRING]$Contestant) { $WebClient = New-Object System.Net.WebClient $Results = $WebClient.DownloadString("https://2011sg.poshcode.org/Reports/TopUsers?filter=Beginner")+$WebClient.DownloadString ("https://2011sg.poshcode.org/Reports/TopUsers?...
PowerShellCorpus/PoshCode/Set vSphere CDP LinkDisc_1.ps1
Set vSphere CDP LinkDisc_1.ps1
function set-vSwitchLinkDiscovery { Param ( #Switch to enable vSwitch Discovery On [Parameter(Mandatory=$true,ValueFromPipeline=$true)] [string] $vSwitchName = "vSwitch0", #Host on which the vSwitch Resides [Parameter(Mandatory=$true,HelpMessage="Need Host Name to connect with")...
PowerShellCorpus/PoshCode/Add-SqlTable_6.ps1
Add-SqlTable_6.ps1
try {add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" -EA Stop} catch {add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo"} try {add-type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8...
PowerShellCorpus/PoshCode/PSTUtility_1.psm1.ps1
PSTUtility_1.psm1.ps1
#============================================================================= # # PST Utilities - For Discovery, Import, Removal # # Dan Thompson # dethompson71 at live dot com # # This collection of tools for importing PSTs has been pieced together # over many months of trial and error. # # Goal is to get ...
PowerShellCorpus/PoshCode/Magister SOAP Webrequest.ps1
Magister SOAP Webrequest.ps1
# Execute-MagisterSOAP.ps1 # We are reading a list of students from a Magister SOAP webrequest. # 20120330 # Paul Wiegmans Clear Set-StrictMode -Version 2 $mijnpad = Split-Path -parent $MyInvocation.MyCommand.Definition Echo "Mijn pad is: $mijnpad " # This is the Magister webquery URL $layout = "Basis" $u...
PowerShellCorpus/PoshCode/Get-RemoteRegistry_1.ps1
Get-RemoteRegistry_1.ps1
## Get-RemoteRegistry ######################################################################################## ## Version: 2.0 ## + I added the "Properties" parameter so you can select specific registry values ## NOTE: you have to have access, and the remote registry service has to be running ####################...
PowerShellCorpus/PoshCode/Get-WebFile 3.1.ps1
Get-WebFile 3.1.ps1
## Get-WebFile.ps1 (aka wget for PowerShell) ############################################################################################################## ## Downloads a file or page from the web ## History: ## v3.1 - Unwrap the filename when it has quotes around it ## v3 - rewritten completely using HttpWebReq...
PowerShellCorpus/PoshCode/New-ObjectRecursive_1.ps1
New-ObjectRecursive_1.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/Send-FTP 1.0.ps1
Send-FTP 1.0.ps1
function Send-FTP { Param( $Server = "ilncenter.net" , $Credentials = $(Get-Credential) , [Parameter(ValueFromPipeline=$true)] $LocalFile , $Path = "/" , $RemoteFile = $(Split-Path $LocalFile -Leaf) , $ParentProgressId = -1 ## Just ignore this ;) ...
PowerShellCorpus/PoshCode/Get-Entropy_1.ps1
Get-Entropy_1.ps1
## function Get-Entropy { <# .SYNOPSIS Calculate the entropy of a byte array. Author: Matthew Graeber (@mattifestation) .PARAMETER ByteArray Specifies the byte array containing the data from which entropy will be calculated. .EXAMPLE C:\\PS> $RandArray = New-Object Byte[](10000) ...
PowerShellCorpus/PoshCode/Get-DefragAnalysis.ps1
Get-DefragAnalysis.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/Resolve-Url.ps1
Resolve-Url.ps1
################################### ## Figure out the real url behind those shortened forms function Resolve-URL([string[]]$urls) { [regex]$snip = "(?:https?://)?(?:snurl|snipr|snipurl)\\.com/([^?/ ]*)\\b" [regex]$tiny = "(?:https?://)?TinyURL.com/([^?/ ]*)\\b" [regex]$isgd = "(?:https?://)?is.gd/([^?...
PowerShellCorpus/PoshCode/AddTo-HostsFile_1.ps1
AddTo-HostsFile_1.ps1
function AddTo-HostsFile{ <# .DESCRIPTION This function checks to see if an entry exists in the hosts file. If it does not, it attempts to add it and verifies the entry. .EXAMPLE Networkign.AddTo-Hosts -IPAddress 192.168.0.1 -HostName MyMachine .EXTERNALHELP None. .FORWARDHELPTARGE...
PowerShellCorpus/PoshCode/Get-Field_2.ps1
Get-Field_2.ps1
function Get-Field{ [CmdletBinding()] param ( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] $InputObject, [Parameter(Position=1,Mandatory=$false)] [string]$Name, [switch]$Force, [switch]$AsHashtable ) $publicNonPublic = [Reflection.BindingFlags]::Public -bor [Reflection...
PowerShellCorpus/PoshCode/Get-PDC09Videos.ps1
Get-PDC09Videos.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 ) Import-Module BitsTransfer $Extension = $(switch -wildcard($MediaType){"wmv*"{"wmv"} "mp4"{"mp4"} "pp...
PowerShellCorpus/PoshCode/New-Shortcut_2.ps1
New-Shortcut_2.ps1
[CmdletBinding()] param ( [parameter(Mandatory=$true)] [ValidateScript( {[IO.File]::Exists($_)} )] [System.IO.FileInfo] $Target, [ValidateScript( {[IO.Directory]::Exists($_)} )] [System.IO.DirectoryInfo] $OutputDirectory, [string] $Name, [string] $Description, [string] $Arguments, [System.I...
PowerShellCorpus/PoshCode/TabExpansion.ps1
TabExpansion.ps1
## Tab-Completion ################# ## Please dot souce this script file. ## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list. ## What this can do is: ## ## [datetime]::n<tab> ## [datetime]::now.d<tab> ## $foo[0].<tab> ## $foo[0].n.b<tab> ## $function:a<tab> ##...
PowerShellCorpus/PoshCode/Is-Prime.ps1
Is-Prime.ps1
######################################################################### # # Is-Prime # #Written by Tynen # ######################################################################### function Is-Prime{ param ($number) if($number -is [int] -or $number -is [long] -or $number -is [double] -or $number -is [sin...
PowerShellCorpus/PoshCode/ShowUI Binary Clock.ps1
ShowUI Binary Clock.ps1
<# .SYNOPSIS Displays a Binary Coded Sexagesimal clock using the ShowUI module. .DESCRIPTION This clock displays time using three rows of blocks. The top row represents hours, the middle is minutes and the bottom is seconds. Each of the six columns represents a binary digit. The values for each digit in the ord...
PowerShellCorpus/PoshCode/New-StoredProcFunction.ps1
New-StoredProcFunction.ps1
# New-StoredProcFunction.ps1 # Steven Murawski # http://blog.usepowershell.com # 04/08/2009 # Example: ./New-StoredProcFunction.ps1 'DataSource=MySqlServer;Database=Northwind;User=AnythingButSa;Password=abc123' sp_createnewcustomer # Example 'sp_createnewcustomer | ./New-StoredProcFunction.ps1 'DataSource=MySqlS...
PowerShellCorpus/PoshCode/Enable-HistoryPersistenc.ps1
Enable-HistoryPersistenc.ps1
##############################################################################\n##\n## Enable-HistoryPersistence\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...
PowerShellCorpus/PoshCode/Add-Namespace_2.ps1
Add-Namespace_2.ps1
trap [System.Management.Automation.RuntimeException] { $entryException = $_ if ($_.CategoryInfo.Category -eq [System.Management.Automation.ErrorCategory]::InvalidOperation) { if ($_.FullyQualifiedErrorId -eq "TypeNotFound") { $targetName = $_.CategoryInfo.TargetName ...
PowerShellCorpus/PoshCode/Get-MemoryChart.ps1
Get-MemoryChart.ps1
#.Synopsis # Draw pie charts of server memory usage by process #.Description # Uses PowerBoots to draw a pipe-chart of each computer's memory use. While you wait for that information # to be gathered, it shows you the latest xkcd comic. ##DEPEND-ON -Function Get-Comic # Uses the Transitionals library for nic...
PowerShellCorpus/PoshCode/Get-ProfilesList_1.ps1
Get-ProfilesList_1.ps1
function Get-ProfilesList { $hive = "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList" gci $hive | % -b {$prof = @()} -p {$dest = "" | select UserName, Sid, ProfilePath $dest.Sid = $_.PSChildName $dest.ProfilePath = (gp ($hive + "\\" + $_.PSChildName)).ProfileImagePath $dest.Us...
PowerShellCorpus/PoshCode/93a65603-30b1-4887-8fef-5b0d188f44a2.ps1
93a65603-30b1-4887-8fef-5b0d188f44a2.ps1
function Using-Culture { <# .SYNOPSIS Runs a PowerShell script under a different locale to test localization features. .DESCRIPTION Runs a PowerShell script under a different locale to test localization features. Copied from http://rkeithhill.wordpress.com/...
PowerShellCorpus/PoshCode/Export-CustomProperty.ps1
Export-CustomProperty.ps1
## An example of how to make a custom object with strongly-typed properties, custom enumeration values, and custom validators, etc. function Export-CustomProperty { param( [Parameter(ValueFromPipeline=$true)] [PSCustomObject]$Object ) process { foreach($property in Get-Member Get_*,Set_* -Input $Objec...
PowerShellCorpus/PoshCode/FastNFS - PowerCLI.ps1
FastNFS - PowerCLI.ps1
# fastNFS # Description: Mounts NFS datastore to a group of ESX hosts. # Usage: Enter a list of ESX hosts (by IP or hostname). Then enter the IP, path, and datastore name of the share. # # # Enter the name or IP of the NFS server $nfssrv = Read-Host "Enter the name or IP of the NFS server" # Enter the full pa...
PowerShellCorpus/PoshCode/Get-Weather_1.ps1
Get-Weather_1.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/Cisco-Inventory.ps1
Cisco-Inventory.ps1
#================================================================================================== # File Name : CiscoInventory.ps1 # Original Author : Kenneth C. Mazie (kcmjr) # Description : As written it will poll Cisco routers and switches and if the snmp OID's # ...
PowerShellCorpus/PoshCode/Stop service and wait....ps1
Stop service and wait....ps1
<# This script stops the service, then waits for the service to stop before continuing with the reboot/shutdown The scritp can be pushed to a server/Pc using Group Policy or Registry or run manually. The shutdown script Registry key is: HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\State\\Ma...
PowerShellCorpus/PoshCode/Get-Parameter.ps1
Get-Parameter.ps1
param($Cmdlet) $CmdletInfo = Get-Command -CommandType Cmdlet -Name $Cmdlet if ( $? ) { if ($CmdletInfo.GetType().Name -eq "CmdletInfo" ) { $parsed = $CmdletInfo.Definition ` -replace "\\] \\[", "]`n[" ` -replace "> \\[", ">`n[" ` -replace "$C...
PowerShellCorpus/PoshCode/image2excel_1.ps1
image2excel_1.ps1
<# .Description image2excel converts image to excel file #> param ( [parameter(Mandatory=$true, ValueFromPipeline=$true, HelpMessage="Image file path" )] [ValidateScript({Test-Path $_})] [String] $filename ) [System.Reflect...
PowerShellCorpus/PoshCode/Get-DLRestriction_1.ps1
Get-DLRestriction_1.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/Get-QADGroupNesting.ps1
Get-QADGroupNesting.ps1
Param ( [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, HelpMessage="DN or ObjectGUID of the AD Group." )] [string]$groupIdentity, [switch]$showTree ) #Validate Quest PSSnapin is loaded Add-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction ...
PowerShellCorpus/PoshCode/Get-WebSite_1.ps1
Get-WebSite_1.ps1
function Get-WebSite { <# .SYNOPSIS Retrieves information about a website. .DESCRIPTION Retrieves information about a website. .PARAMETER Url URL of the website to test access to. .PARAMETER UseDefaultCredentials Use the currently authenticated user's credentials .PARAMETER Proxy Us...
PowerShellCorpus/PoshCode/Get-HostsFile.ps1
Get-HostsFile.ps1
Function Get-HostsFile { <# .SYNOPSIS Retrieves the contents of a hosts file on a specified system .DESCRIPTION Retrieves the contents of a hosts file on a specified system .PARAMETER Computer Computer name to view host file from .NOTES Name: Get-HostsFile Author: Boe Prox DateCre...
PowerShellCorpus/PoshCode/Get-GrowthRate.ps1
Get-GrowthRate.ps1
function Get-GrowthRate { param( $Start, $End, $Period ) $rate = [math]::Abs( [math]::Pow( ( $End / $Start ),( 1 / $per - 1 ) ) - 1 ) "{0:P}" -f $rate }
PowerShellCorpus/PoshCode/Get-DellWarranty by API.ps1
Get-DellWarranty by API.ps1
## Dane Kantner 4/19/2013 ## $computers="localhost","Chiv5908-2009","anyothercomputers","NYSPC-JJAJ68YG6" foreach ($computer in $computers) { $obj=get-wmiobject win32_systemenclosure -computername $computer -ErrorAction SilentlyContinue if ($obj -eq $null) { # unable to retrieve, system may be offline...
PowerShellCorpus/PoshCode/Test-Port_3.ps1
Test-Port_3.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/Logger.psm1 0.4.ps1
Logger.psm1 0.4.ps1
<# Name : Universal Log4Net Logging Module (Logger.psm1) Version : 0.3 Author : Joel Bennett (MVP) Site : http://www.HuddledMasses.org/ Version History: 0.4 - Bugfix, Viewer and Documentation release. Fixed a few typo-bugs Added documentation (man page) comments ...
PowerShellCorpus/PoshCode/NetSnmp.psm1.ps1
NetSnmp.psm1.ps1
#requires -version 2 $NetSnmp = Join-Path $env:programfiles "Net-SNMP\\bin" if ( -not ( Test-Path "$NetSnmp\\snmpwalk.exe" ) ) { Throw "Net-SNMP binaries not found in $NetSnmp. Please install to this folder ` or edit the NetSnmp variable as appropriate." } # Modeled after SNMPWALK http://www.net-snmp.org...
PowerShellCorpus/PoshCode/_3.168.1.1.ps1
_3.168.1.1.ps1
function Set-IPAddress { param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"), [string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"), [string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"), [string]$gateway = $(read-host "Enter...
PowerShellCorpus/PoshCode/Grant-RegistryAccessFull.ps1
Grant-RegistryAccessFull.ps1
##############################################################################\n##\n## Grant-RegistryAccessFullControl\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNO...
PowerShellCorpus/PoshCode/UIAutomation.ps1
UIAutomation.ps1
# # # Select-Window Notepad | Remove-Window -passthru # # ## And later ... # # Select-Wi...
PowerShellCorpus/PoshCode/Get-OnlineHelp_1.ps1
Get-OnlineHelp_1.ps1
## An update using New-WebServiceProxy to the MSDN ContentService instead of HttpRest ## See: http: //services.msdn.microsoft.com/ContentServices/ContentService.asmx ## This is a VERY EARLY prototype of a function that could retrieve cmdlet help from TechNet ... ## and hypothetically, other online help sites which...
PowerShellCorpus/PoshCode/HTML Parse Demo.ps1
HTML Parse Demo.ps1
$page = Invoke-WebRequest "http://www.apk.se" $html = $page.parsedHTML $products = $html.body.getElementsByTagName("TR") $headers = @() foreach($product in $products) { $colID = 0; $hRow = $false $returnObject = New-Object Object foreach($child in $product.children) { if ($child.tagName -eq "TH") ...
PowerShellCorpus/PoshCode/get-ESXiHostConfigBackup_2.ps1
get-ESXiHostConfigBackup_2.ps1
<# .SYNOPSIS Creates config bundle backup for ESXi hosts. Works where 80 is blocked to ESXi host Originally script by Alan Renouf (http://www.virtu-al.net/2011/02/23/backing-up-the-esxi-system-image) Heavily Modified by Jimmy Hester .DESCRIPTION Checks for connection to a vCenter or ESXi server If not connected...
PowerShellCorpus/PoshCode/PowerWatin 0.5.ps1
PowerWatin 0.5.ps1
## CHANGE this to point to your WatiN.Core.dll $WatinPath = Convert-Path (Resolve-Path "$(Split-Path $Profile)\\Libraries\\Watin2\\WatiN.Core.dll") ## Load the assembly $global:watin = [Reflection.Assembly]::LoadFrom( $WatinPath ) $WFind = [Watin.Core.Find] ## The rest of this is generated ... I've pasted the ...
PowerShellCorpus/PoshCode/TruncatePath_3.ps1
TruncatePath_3.ps1
### # TruncatePath # Version 1.0.6 (05 Nov 2008) # Description: Replaces long provider paths in the prompt with ellipses # Notes: Place in your profile # # By Mike Hays, http://www.mike-hays.net ### $maxPathLength = 40 $showFullPath = $false Function Prompt { $currentPath = (Get-Location).Path ...
PowerShellCorpus/PoshCode/Get-SqlWmi_1.ps1
Get-SqlWmi_1.ps1
try {add-type -AssemblyName "Microsoft.SqlServer.SqlWmiManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" -EA Stop} catch {add-type -AssemblyName "Microsoft.SqlServer.SqlWmiManagement"} ####################### <# .SYNOPSIS Gets SQL Server WMI information. .DESCRIPTION The Get-SqlWm...
PowerShellCorpus/PoshCode/Get-GrowthRate_4.ps1
Get-GrowthRate_4.ps1
function Get-GrowthRate { param( $Start, $End, $Period ) @@ $rate = [math]::Abs( [math]::Pow( ( $End / $Start ),( 1 / $Period - 1 ) ) - 1 ) "{0:P}" -f $rate }
PowerShellCorpus/PoshCode/Get-Field.ps1
Get-Field.ps1
function Get-Field{ [CmdletBinding()] param ( [Parameter(Position=0,Mandatory=$true)] $InputObject ) $type = $InputObject.gettype() $publicNonPublic = [Reflection.BindingFlags]::Public -bor [Reflection.BindingFlags]::NonPublic $instance = $publicNonPublic -bor [Reflection.BindingFlags]::Instance...
PowerShellCorpus/PoshCode/ISE-FileName.ps1
ISE-FileName.ps1
#requires -version 2.0 ## ISE-FileName module v 1.0 ############################################################################################################## ## Provides File and Path cmdlets for working with ISE ## Copy-ISEFullPath - Copy the full path of the current file to the clipboard ## Copy-ISEPath - C...
PowerShellCorpus/PoshCode/Set-SendAs.ps1
Set-SendAs.ps1
# NAME # Set-SendAs # # SYNOPSIS # Use the Set-SendAs cmdlet to grant or Remove SendAs permissions on a mailbox # # SYNTAX # Set-SendAs -Identity <MailboxIdParameter> -SendAs <MailboxIdParameter> -ou <OrganizationalUnit> [-Remove <SwitchParameter> [-Confirm [<SwitchParameter>]]] [-DomainController <Fqdn>] ...
PowerShellCorpus/PoshCode/update-powerpackcolumns.ps1
update-powerpackcolumns.ps1
################################################################### # Update Columns in PowerPacks ################################################################### # (c) Dmitry Sotnikov # http://dmitrysotnikov.wordpress.com ################################################################### # This script is de...
PowerShellCorpus/PoshCode/Download DefragTools .ps1
Download DefragTools .ps1
#requires -version 2.0 <# .Synopsis Downloads Channel 9 Defrag Tool Episode Video .DESCRIPTION Downloads Channel 9 Defrag Tool Episode Video in the format selected and to a given path. .EXAMPLE Downloads all shows in WMV format to the default Downloads Folder for the user. Get-DefragToolsShow -All...
PowerShellCorpus/PoshCode/chkhash_6.ps1
chkhash_6.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/chkhash_9.ps1
chkhash_9.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/Audit Script_1.ps1
Audit Script_1.ps1
##################################################### # # Audit script by Alan Renouf - Virtu-Al # # # Blog: http://teckinfo.blogspot.com/ # # # # # # Usage: Audit.ps1 'path' # # # ...
PowerShellCorpus/PoshCode/GPRS Online log_4.ps1
GPRS Online log_4.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/d0047a4f-cc03-41f0-ba05-197bd8b5f759.ps1
d0047a4f-cc03-41f0-ba05-197bd8b5f759.ps1
Coresponding to the Scripting Guy blog "How Can I Both Save Information in a File and Display It on the Screen? " (http://blogs.technet.com/heyscriptingguy/archive/2009/07/07/hey-scripting-guy-how-can-i-both-save-information-in-a-file-and-display-it-on-the-screen.aspx): My comment is: "All of the above is cool but c...
PowerShellCorpus/PoshCode/ScheduleGPOBackups_2.ps1
ScheduleGPOBackups_2.ps1
Import-Module grouppolicy #region ConfigBlock # What domain are we going to backup GPOs for? $domain = "mydomain.com" # Where are we going to store the backups? $gpoBackupRootDir = "c:\\gpoBackups" # As I plan to do a new backup set each month I'll setup the directory names to reflect # the year and month in a n...
PowerShellCorpus/PoshCode/Get-BogonList_1.ps1
Get-BogonList_1.ps1
function Get-BogonList { <# .SYNOPSIS Gets the bogon list. .DESCRIPTION The Get-BogonList function retrieves the bogon prefix list maintained by Team Cymru. A bogon prefix is a route that should never appear in the Internet routing table. A packet routed over the public Internet (not including o...
PowerShellCorpus/PoshCode/Check Service on Servers.ps1
Check Service on Servers.ps1
<# Author: Matt Schmitt Date: 11/29/12 Version: 1.0 From: USA Email: ithink2020@gmail.com Website: http://about.me/schmittmatt Twitter: @MatthewASchmitt Description A script for checking the status of a service on a group of servers, from a list in a file. #> $...
PowerShellCorpus/PoshCode/Issue-PendingRequest_1.ps1
Issue-PendingRequest_1.ps1
##################################################################### # Issue certificate.ps1 # Version 1.0 # # Issues certificate request from a pending request # # For this function to succeed, the certificate request must be pending # # Vadims Podans (c) 2010 # http://en-us.sysadmins.lv/ ##################...
PowerShellCorpus/PoshCode/Set-IPConfigv2.ps1
Set-IPConfigv2.ps1
# script parameters param( [string[]] $Computers = $env:computername, [switch] $ChangeSettings, [switch] $EnableDHCP, [switch] $Batch ) $nl = [Environment]::NewLine # check for Admin rights if ($ChangeSettings -or $EnableDHCP){ If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdenti...
PowerShellCorpus/PoshCode/Set-Domain_7.ps1
Set-Domain_7.ps1
function Set-Domain { param( [switch]$help, [string]$domain=$(read-host "Please specify the domain to join"), [System.Management.Automation.PSCredential]$credential = $(Get-Crdential) ) $usage = "`$cred = get-credential `n" $usage += "Set-Domain -domain MyDomain -credential `$cred`n" if ($help...
PowerShellCorpus/PoshCode/Inovke command exclusive.ps1
Inovke command exclusive.ps1
function Invoke-CommandEx { param ( [String] $MutexName = $(throw "Name is required."), [ScriptBlock] $Scriptblock = $(throw "Scriptblock is required."), [Object[]] $ArgumentList ) $MutexWasCreated = $false; $Mutex = $null; Write-Host "Waiting to acquire lock [$MutexName]..." -f Cyan [System.Ref...
PowerShellCorpus/PoshCode/Impersonation 1.1.ps1
Impersonation 1.1.ps1
# Version History # 1.1 - Added aliases, error handling, help, and cleanup $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { while($script:ImpContextStack.Count) { Pop-ImpersonationContext } } $script:UserToysClass = Add-Type -Namespace Huddled -Name UserToys -MemberDefinition @" // http://msdn....
PowerShellCorpus/PoshCode/foreach-withexception_1.ps1
foreach-withexception_1.ps1
function foreach-withexception ([scriptblock]$process,$outputexception) { begin { $global:foreachex = @() } process { try { $local:inputitem = $_ &$process } catch { $local:exceptionitem = 1 | select-object...
PowerShellCorpus/PoshCode/PowerBot _2.0.ps1
PowerBot _2.0.ps1
## PowerBot 2.0 ## A simple framework to get you started writing your own IRC bots in PowerShell #################################################################################################### ## Requires Meebey.SmartIrc4net.dll to be in your ...\\WindowsPowerShell\\Libraries\\ ## You can get Meebey.SmartIrc4n...
PowerShellCorpus/PoshCode/sudo for Powershell_4.ps1
sudo for Powershell_4.ps1
## sudo.ps1 # # Authors: rbellamy, 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%98sud...
PowerShellCorpus/PoshCode/Get-Environment.ps1
Get-Environment.ps1
Param($srv=$env:ComputerName) $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Srv) $key = $regKey.OpenSubkey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",$false) $key.GetValueNames() | Select-Object @{n="ValueName";e={$_}},@{n="Value";e={...