full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Autoload (beta 5).ps1
Autoload (beta 5).ps1
#Requires -Version 2.0 ## Version History ## beta 5 - 2010.05.10 ## Fixed non-pipeline use using $MyInvocation.ExpectingInput ## beta 4 - 2010.05.10 ## I made a few tweaks and bug fixes while testing it's use with PowerBoots. ## beta 3 - 2010.05.10 ## fix for signed scripts (strip si...
PowerShellCorpus/PoshCode/Patch-VMHost.ps1
Patch-VMHost.ps1
Add-PSSnapin "VMware.VimAutomation.Core" Add-PSSnapIn "VMware.VumAutomation" # Connect to vCenter $VC = Connect-VIServer (Read-Host "Enter vCenter server") $vumConfig = Get-VumConfig $EsxHost = Get-Inventory -Name (Read-Host "Enter ESX Host") $CriticalHost = Get-Baseline -Name "Critical Host Updates" $NonCr...
PowerShellCorpus/PoshCode/PowerCLI New-Farm.ps1
PowerCLI New-Farm.ps1
# Connect to vCenter Connect-VIServer vcenter.domain.com # root folder is used for datacenter location $rootfolder = Get-Folder -NoRecursion # datacenter $dc = New-Datacenter -Name "vFarm" -Location $rootfolder # Build hostname strings for ESX servers in format sssrrrnn (site/role/number) $esxname = 1..10 ...
PowerShellCorpus/PoshCode/986fdfec-754f-49c7-8315-a67f47f16823.ps1
986fdfec-754f-49c7-8315-a67f47f16823.ps1
If ([intptr]::size -eq 4) { $powerShellDir = $powershelldir = "$env:Windir\\Sysnative\\WindowsPowerShell\\V1.0\\" $dir = "& `"$env:ProgramFiles\\Check_MK\\plugins\\Ex2010_MBDB_Info.ps1`"" $bytes = [Text.Encoding]::Unicode.GetBytes($dir) $encodedCommand = [Convert]::ToBase64String($bytes) Invoke-Command -comma...
PowerShellCorpus/PoshCode/3c9c5d54-adf5-44bb-bf12-ab18d089e443.ps1
3c9c5d54-adf5-44bb-bf12-ab18d089e443.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-Constructor_3.ps1
Get-Constructor_3.ps1
function Get-Constructor { PARAM( [Type]$type, [Switch]$Simple) if($Simple) { $type.GetConstructors() | Select @{ l="$($type.Name) Constructor" e={ "New-Object $($type.FullName) $(($_.GetParameters() | ForEach { "[{0}]`${1}" -f $_.ParameterType.FullName, $_.Name }) -Join ", ")" } ...
PowerShellCorpus/PoshCode/Send mail to BCC.ps1
Send mail to BCC.ps1
<# .SYNOPSIS Send mail to BCC using PowerShell .DESCRIPTION This script is a re-developed MSDN Sample using PowerShell. It creates an email message then sends it with a BCC. .NOTES File Name : Send-BCCMail.ps1 Author : Thomas Lee - tfl@psp.co.uk Requires : PowerShell V2 CTP3 .LINK ...
PowerShellCorpus/PoshCode/Get-Application 2.1.ps1
Get-Application 2.1.ps1
function Find-Application { [CmdletBinding()] param( [string]$Name ) begin { [String[]]$Path = (Get-Content Env:Path).Split(";") | ForEach-Object { if($_ -match "%.*?%"){ $expansion = Get-Content ($_ -replace '.*%(.*?)%.*','Env:$1') ...
PowerShellCorpus/PoshCode/Exchange07 Mbox Report.ps1
Exchange07 Mbox Report.ps1
#This script is designed to grab mailbox statistics for every user and give a more detailed #level of output about mailbox statistics in .html format param( [string] $SFileWDir ) # If there is no optional argument then make a filename for it. if (!$SFileWDir) { Write-Host "You didn't specify a filename w/...
PowerShellCorpus/PoshCode/Get-DiskUsage.ps1
Get-DiskUsage.ps1
## du.ps1 Get-DiskUsage ############################### ## Note: $unit can be: kb, mb, gb, or an empty string (to get bytes) ############################### ## -Force causes du to include System ReparsePoints ## This means including folders like Vista's ~\\Documents\\My Pictures (which is a symlink to ~\\Pictur...
PowerShellCorpus/PoshCode/Get-LatestChromium.ps1
Get-LatestChromium.ps1
$sevenz = 'D:\\u\\7-Zip\\current\\7z.exe' $drops = 'D:\\chromium\\drops' $VerbosePreference = 'Continue' $wc = New-Object Net.WebClient $url = 'http://build.chromium.org/buildbot/snapshots/chromium-rel-xp' Write-Verbose 'Finding the latest build...' $latest = [Int32]$wc.DownloadString("$url/LATEST") if (...
PowerShellCorpus/PoshCode/ConvertTo-ASCII_1.ps1
ConvertTo-ASCII_1.ps1
#requires �version 2.0 #region Help <# .SYNOPSIS Automation script for file character set format conversion to ASCII encoding. .DESCRIPTION Script for automating the conversion of files to ASCII format. Good for if you've used Out-File without specifying the encoding. Which would make a Unicode formatt...
PowerShellCorpus/PoshCode/Remove broken NTFS perm.ps1
Remove broken NTFS perm.ps1
#========================================================================== # NAME: getunknownsids.ps1 # # AUTHOR: Stephen Wheet # Version: 4.0 # Date: 6/11/10 # # COMMENT: # This script was created to find unknown SIDs or old domain permissions # on folders. It ignores folders where inheirtance is turned ...
PowerShellCorpus/PoshCode/Get-LocalGroupMember_2.ps1
Get-LocalGroupMember_2.ps1
function Get-LocalGroupMember { param( # The name of the local group to retrieve members of [Parameter(Position=0,Mandatory=$true)] [String]$GroupName = "administrators", # A filter for the user name(s) [Parameter(Position=1)] [String]$UserName = "*", # The computer to query (defaults ...
PowerShellCorpus/PoshCode/vProfile-ClusterAudit.ps1
vProfile-ClusterAudit.ps1
# vProfile-ClusterAudit.ps1 : vSphere cluster node auditing script # This script will compare all VI/vSphere cluster nodes against a reference node # Parameters: # $xmlFile : XML profile file, created by the vProfile.ps1 script # $csvFile : CSV file that will conatin the discovered differences # $referenceHost : h...
PowerShellCorpus/PoshCode/Findup_19.ps1
Findup_19.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/Set-Wallpaper (CTP3).ps1
Set-Wallpaper (CTP3).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/Portgroup NIC Team.ps1
Portgroup NIC Team.ps1
# PG-duplex.ps1 : NIC Teaming with failover set on duplexity # This script will configure the portgroup to use NIC Teaming where the failover is # depending on the duplexity of the Active NIC. # # Parameters: # $esxName : name of the ESX server # $vSwitch : name of the vSwitch # $portgroup : name of the portgrou...
PowerShellCorpus/PoshCode/e5112c21-82dc-44c8-8fa5-616b1b16b004.ps1
e5112c21-82dc-44c8-8fa5-616b1b16b004.ps1
#region Function: Get-DTWFileEncoding <# .SYNOPSIS Returns the encoding type of the file .DESCRIPTION Returns the encoding type of the file. It first attempts to determine the encoding by detecting the Byte Order Marker using Lee Holmes' algorithm (http://poshcode.org/2153). However, if the file does not ...
PowerShellCorpus/PoshCode/Create-Sequence.ps1
Create-Sequence.ps1
# Create-Sequence.ps1 # requires -version 1 # # Create a sequence object similar to an Oracle sequence. # # see : http://www.acs.ilstu.edu/docs/oracle/server.101/b10759/statements_6014.htm # # Crée un objet séquence similaire à une séquence Oracle # Version spécifique à PowerShell v1.0 # L'appel de Nextval n...
PowerShellCorpus/PoshCode/SqlProxy.psm1.ps1
SqlProxy.psm1.ps1
# --------------------------------------------------------------------------- ### <Author> ### Chad Miller ### </Author> ### <Description> ### Based on functions in SQLPSX. SqlProxy.psm1 module is used for administering ### SQL Server logins, users, and roles. Designed to be used with PS Remoting. ### All actio...
PowerShellCorpus/PoshCode/McAfeeAPI_01Connect.ps1
McAfeeAPI_01Connect.ps1
#region << ePO Connection and Initialization >> function McAfee-Connect{ param([String]$script:ServerURL="SERVERNAME:8443") $c = McAfee-Credential $script:wc = McAfee-WebClient -Credential $c } function McAfee-Credential{ $c = Get-Credential -Credential $null return $c } function McAfee-WebClient{ ...
PowerShellCorpus/PoshCode/Get-Scope_2.ps1
Get-Scope_2.ps1
function Get-Scope{ $rtnScope = 0 $global:scope = $false $scope = $true while($($ErrorActionPreference = "silentlycontinue"; switch((get-Variable -Name scope -Scope $rtnScope).value){$null{$true} $true{$true} $false{$ErrorActionPreference = "continue"; return ($rtnScope - 1)}})){ $rtnScope+...
PowerShellCorpus/PoshCode/set-ipconfigv6.ps1
set-ipconfigv6.ps1
# script parameters param( [Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)] [alias("Name","ComputerName")][string[]]$Computers = @($env:computername), $Domain = "domain.local", $DNSSuffix = @("domain.local,sub.domain.local,domain.com"), $DNSServers = @("10.10.0.1", "10.10.0.2"...
PowerShellCorpus/PoshCode/Get-NestedGroups.ps1
Get-NestedGroups.ps1
<# .SYNOPSIS Enumerate all AD group memberships of an account (including nested membership). .DESCRIPTION This script will return all the AD groups an account is member of. .PARAMETER UserName The username whose group membershipts to find. .EXAMPLE .\\Get-NestedGroups.ps1 'johndoe' Name ...
PowerShellCorpus/PoshCode/Restore-Database.ps1
Restore-Database.ps1
param($sqlserver, $filepath) #Note: Uses Changeset 59378 or higher of SQLPSX SQLServer module http://sqlpsx.codeplex.com/SourceControl/changeset/view/58378#564810 #Added FileListOnly option to Invoke-SqlRestore. The option will be included in releases after 2.3.1 import-module sqlserver -force $server = get...
PowerShellCorpus/PoshCode/Findup_21.ps1
Findup_21.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/Parse-ApacheRedirects.ps1
Parse-ApacheRedirects.ps1
<# .SYNOPSIS Parses an Apache redirect file to identify broken entries. .DESCRIPTION All redirects will be followed and the final response code will be processed as follows: 200 - OK 401 - OK 403 - Broken 404 - Broken *** - Optionally remove with -RemoveUnknownEr...
PowerShellCorpus/PoshCode/Get-Exchange-Mail_2.ps1
Get-Exchange-Mail_2.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/get-netstat 1.3.ps1
get-netstat 1.3.ps1
$netstat = netstat -a -n -o | where-object { $_ -match "(UDP|TCP)" } [regex]$regexTCP = '(?<Protocol>\\S+)\\s+((?<LAddress>(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?))|(?<LAddress>\\[?[0-9a-fA-f]{0,4}(\\:([0-9a-fA-f]{0,4})){1...
PowerShellCorpus/PoshCode/Ring Monitor.ps1
Ring Monitor.ps1
#requires -version 2.0 Import-Module Accelerators # http://poshcode.org/762 Import-Module PowerBoots # http://boots.codeplex.com # http://dynamicdatadisplay.codeplex.com ## You have to get the DynamicDataDisplay control, and put it's DLLs in the PowerBoots folder... ls "$PowerBootsP...
PowerShellCorpus/PoshCode/Language.ps1
Language.ps1
## Language.ps1 includes Resolve-Language, Get-English, and Resolve-Anagram ################################################################################################### ## Some language functions, including a language guessing script using a web form ## Xerox Research Center Europe (www.xrce.xerox.com) which...
PowerShellCorpus/PoshCode/PowerShell Template_6.ps1
PowerShell Template_6.ps1
Function new-script { $strName = $env:username $date = get-date -format d $name = Read-Host "Filename" $email = Read-Host "eMail Address" $file = New-Item -type file "c:\\Scripts\\$name.ps1" -force add-content $file "#==========================================================================" add-content $file ...
PowerShellCorpus/PoshCode/Search AD Forest.ps1
Search AD Forest.ps1
######################################################################################## ## Search Active Directory Forest ## Search-ADForest ######################################################################################## ## NOTE: You have to have sufficient privileges on the target domain for this to work...
PowerShellCorpus/PoshCode/Exif query script.ps1
Exif query script.ps1
## Selected 'Exif' statistics script is below. There are a number of ways I can improve it: ## Stream output, skip csv file creation (as an interim step) read list with arrays and parameters, ## using regex expressions to best effect. Still, quite a few lessons learned with this and the output can help ## check fo...
PowerShellCorpus/PoshCode/Get-Payment_1.ps1
Get-Payment_1.ps1
function Get-Payment { param ( $LoanAmount, [double]$InterestRatePerPeriod, $NumberPayments ) $a = $LoanAmount $b = $InterestRatePerPeriod*[math]::Pow(($InterestRatePerPeriod + 1),$NumberPayments) $c = [math]::Pow((1+$InterestRatePerPeriod),$NumberPayments) - 1 $payment = $a*($b/$c) "{0:C}" -f $payment }
PowerShellCorpus/PoshCode/Test-Hash_1.ps1
Test-Hash_1.ps1
function Test-Hash { #.Synopsis # Test the HMAC hash(es) of a file #.Description # Takes the HMAC hash of a file using specified algorithm, and optionally, compare it to a baseline hash #.Example # C:\\PS>ls .\\Bin\\Release -recurse | Test-Hash -BasePath .\\Bin\\Release -Type SHA256 | Export-CSV ~\\Hashes....
PowerShellCorpus/PoshCode/Set-SecureAutoLogon_1.ps1
Set-SecureAutoLogon_1.ps1
[cmdletbinding()] param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string] $Username, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.Security.SecureString] $Password, [string] $Domain, [Int] $AutoLogonCount, [switch] $RemoveLegalPrompt, [System.IO.Fi...
PowerShellCorpus/PoshCode/Update Subnet Masks.ps1
Update Subnet Masks.ps1
#config @@#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@#NOTE: Does not support IPv6. If used on a network with static IPv6 addresses, @@#they may be lost. @@#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@$network = "10.200.*" @@$newSubnet = ...
PowerShellCorpus/PoshCode/Start-RDP.ps1
Start-RDP.ps1
######################################################################################################################## # NAME # Start-RDP # # SYNOPSIS # Opens a remote desktop connection to another computer. # # SYNTAX # Start-RDP [[-Server] <string>] [[-Width] <int>] [[-Height] <int>] # Star...
PowerShellCorpus/PoshCode/Function Run-Script_1.ps1
Function Run-Script_1.ps1
function Run-Script { if ($psISE.CurrentFile.DisplayName.StartsWith("Untitled")) { return } $script = $psISE.CurrentFile.DisplayName $psISE.CurrentFile.Save() $logfile = "$env:programfiles\\Sea Star Development\\" + "Script Monitor Service\\ScriptMon.txt" #Change t...
PowerShellCorpus/PoshCode/ce50f222-81f6-4509-90ad-8904f9331d7c.ps1
ce50f222-81f6-4509-90ad-8904f9331d7c.ps1
# Detect 32 or 64 bits Windows – regardless of WoW64 – with the PowerShell OSArchitecture function # By Vincent Hoogendoorn @@# See http://vincenth.net/blog/archive/2009/11/02/detect-32-or-64-bits-windows-regardless-of-wow64-with-the-powershell-osarchitecture-function.aspx for details. @@# For the used InvokeCSharp ...
PowerShellCorpus/PoshCode/hex2dec_3.ps1
hex2dec_3.ps1
@echo off ::interactive mode if "%1" equ "" ( if not defined run goto:interactive goto:error ) ::null results for %%i in ("x0" "0x0") do if "%1" equ "%%~i" goto:null ::parsing arguments setlocal enabledelayedexpansion ::only one argument should input set "arg=0" for %%i in ...
PowerShellCorpus/PoshCode/usr ActiveSync - Exch 07.ps1
usr ActiveSync - Exch 07.ps1
#Sacamos los dispositivos asociados a cada mailbox #Verificamos su ultima conexión o si alguna vez no se han conectado #Autor: Pedro Genil #Fecha:23/11/2012 #Version: 1.0 If ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null) { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin }...
PowerShellCorpus/PoshCode/Install-ISPackage.ps1
Install-ISPackage.ps1
####################### <# .SYNOPSIS Installs an SSIS package to a SQL Server store. .DESCRIPTION The Install-ISPackage script installs an Dtsx file to a SQL Server store using the command-line utility dtutil. Works for 2005 and higher .EXAMPLE ./install-ispackage.ps1 -DtsxFullName "C:\\Users\\Public\\bin\\SSIS...
PowerShellCorpus/PoshCode/New-Password 1.1.ps1
New-Password 1.1.ps1
#.Synopsis # Generate pseudo-random passwords based on templates # #.Parameter Template # The template for the password you want to generate. This defines which types of characters are generated for each character in the password. # IMPORTANT: the US English alphabet is hardcoded ... (we make no apologies, but...
PowerShellCorpus/PoshCode/Send-SMSMessage.ps1
Send-SMSMessage.ps1
#requires -version 2 function Send-SMSMessage { <# .SYNOPSIS Send a Text Message (SMS) using Microsoft Outlook .DESCRIPTION Sends a Text Message (SMS) using the supplied parameters. .PARAMETER To Telephone number to send the text message to. .PARAMETER Message The message to send. .EXAMPLE Send-SMSMessag...
PowerShellCorpus/PoshCode/Start-Verify_2.ps1
Start-Verify_2.ps1
# Author: Steven Murawski http://www.mindofroot.com # This script creates two functions (and a helper function). One starts logging all commands entered, # and the second removes the logging. # This script is similar to the Start-Transcript, but only logs the command line and not the output. # Modified to add ...
PowerShellCorpus/PoshCode/PS2WCF_7.ps1
PS2WCF_7.ps1
<# .SYNOPSIS Functions to call WCF Services With PowerShell. .NOTES Version 1.2 11.02.2012 Requires Powershell v2 and .NET 3.5 Copyright (c) 2008 Christian Glessner Copyright (c) 2012 Justin Dearing Permission is hereby granted, free of charge, to any person obtaining a copy of this software an...
PowerShellCorpus/PoshCode/New-Choice_1.ps1
New-Choice_1.ps1
function New-Choice { <# .SYNOPSIS The New-Choice function is used to provide extended control to a script author who writing code that will prompt a user for information. .PARAMETER Choices An Array of Choices, ie Yes, No and Maybe .PARAMETER Caption Caption to present to end user ...
PowerShellCorpus/PoshCode/BufferBox _1.6.ps1
BufferBox _1.6.ps1
#################################################################################################### ## This script is just a demonstration of some of the things you can do with the buffer ## in the default PowerShell host... it serves as a reminder of how much work remains on ## PoshConsole, and as an inspiration t...
PowerShellCorpus/PoshCode/New-FilesystemHardLink.p.ps1
New-FilesystemHardLink.p.ps1
##############################################################################\n##\n## New-FileSystemHardLink\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\nC...
PowerShellCorpus/PoshCode/Backup Hyper-V VMs.ps1
Backup Hyper-V VMs.ps1
# Directions for use: # Import this script using the Import-Module cmdlet # All output is logged to the backup directory in the $($BackupDriveLetter):\\VMBackup\\Backup-VMs.log file # Use the Backup-VMs cmdlet to begin the process # Parameter BackupDriveLetter indicates the drive to put this backup onto. It must b...
PowerShellCorpus/PoshCode/Get-CrystalReportTable.ps1
Get-CrystalReportTable.ps1
function Get-CrystalReportTable() { #Requires -Version 2 <# .Synopsis Examines a Crystal Report and returns the tables used .Description Examines a Crystal Report and returns the tables used by the main report and subreports .Example $reports = Dir *.rpt | Get-Crysta...
PowerShellCorpus/PoshCode/SqlProxy_1.psm1.ps1
SqlProxy_1.psm1.ps1
# --------------------------------------------------------------------------- ### <Author> ### Chad Miller ### </Author> ### <Description> ### Based on functions in SQLPSX. SqlProxy.psm1 module is used for administering ### SQL Server logins, users, and roles. Designed to be used with PS Remoting. ### All actio...
PowerShellCorpus/PoshCode/e3d743cf-73b0-4cbc-b91e-bf279e52655e.ps1
e3d743cf-73b0-4cbc-b91e-bf279e52655e.ps1
param( [string] $dirRoot = ".", [string] $Spec = "*.*" ) # # Description: # Use the wide unicode versions (FindFirstFileW and FindNextFileW) to report a directory listing of all files, including those that exceed the MAX_PATH ANSI limitations # # Assumptions, this script works on the assumption that...
PowerShellCorpus/PoshCode/GPRS Online log_7.ps1
GPRS Online log_7.ps1
<# .SYNOPSIS Get-GprsTime (V4.0 Update for Windows 7 and allow time correction) Check the total connect time of any GPRS devices from a specified date. Use 'Get-Help .\\Get-GprsTime -full' to view Help for this script. .DESCRIPTION Display all the GPRS modem Event Log entries. While applications issued by the ...
PowerShellCorpus/PoshCode/Select-Alive.ps1
Select-Alive.ps1
filter Select-Alive { param ( [switch]$Verbose ) trap { Write-Verbose "$(get-date -f 's') ping failed: $computer" continue } if ($Verbose) { $VerbosePreference = "continue" $ErrorActionPreference = "continue" } else { $VerbosePreference = "silentlycontinue" $ErrorActionPreference = "silent...
PowerShellCorpus/PoshCode/ConvertFrom-FahrenheitWi_1.ps1
ConvertFrom-FahrenheitWi_1.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 it to Celsius\n$celsius = $fahrenheit - 32\n$celsius = $celsius / 1.8\n\n## Output the answer\n"$fahrenheit degrees Fahrenheit is $celsius degr...
PowerShellCorpus/PoshCode/Set Logfile length_1.ps1
Set Logfile length_1.ps1
################################################################################ # Set-FileLines.ps1 # This script will maintain the PS Transcript file, or any text file, at a fixed # length and can be used to prevent such files from becoming too large, with the # option of removing any blank lines. Defaults to 10...
PowerShellCorpus/PoshCode/Check latest BIOS Rev_2.ps1
Check latest BIOS Rev_2.ps1
$BiosRev = Get-WmiObject -Class Win32_BIOS -ComputerName $ComputerName -Credential $Credentials # Shortened URL for the Dell Support page, fileid=441102, appears to be the identifier for BIOS downloads # I tested this on a few different models of Dell workstations. $DellBIOSPage = "http://support.dell.com/suppor...
PowerShellCorpus/PoshCode/Get-OleDBPSObject.ps1
Get-OleDBPSObject.ps1
function Get-OleDBPSObject ([string]$ConnectionString, [string]$Query) { $ConnObj = new-object System.Data.OleDb.OleDbConnection $ConnectionString $command = New-Object System.Data.OleDb.OleDbCommand $Query, $ConnObj try { $ConnObj.Open() [System.Data.OleDB.OleDbDataReader]$reader = $command.ExecuteReader()...
PowerShellCorpus/PoshCode/Create VMKernel on vDS.ps1
Create VMKernel on vDS.ps1
@@ New-VMHostNetworkAdapter -VMHost $myHost -VirtualSwitch "myVDS"-PortGroup "vdPortGroup"
PowerShellCorpus/PoshCode/FuncionInfo_1.types.ps1xml.ps1
FuncionInfo_1.types.ps1xml.ps1
<?xml version="1.0" encoding="utf-8" ?> <Types> <Type> <Name>System.Management.Automation.FunctionInfo</Name> <Members> <ScriptProperty> <Name>Verb</Name> <GetScriptBlock> if ($this.Name.Contains("-")) { $this.Name.Substring(0,$this.Name.Indexof("-")) } else { $null ...
PowerShellCorpus/PoshCode/Security group monitor_2.ps1
Security group monitor_2.ps1
#Get group membership for a list of security #groups and export to an XML for comparison #against baseline. # $script:WorkingDirectory = split-path $myinvocation.Mycommand.Definition -parent Function Re-Baseline { #First, declare array and hashtable. $securitygroups = @() $table = @{} #Import Security...
PowerShellCorpus/PoshCode/Get-User_2.ps1
Get-User_2.ps1
function Get-User($user) { # this function should be passed the CN of the user to be returned $dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() $root = [ADSI] "LDAP://$($dom.Name)" $searcher = New-Object System.DirectoryServices.DirectorySearcher $root $searcher.filter = "(&(objec...
PowerShellCorpus/PoshCode/NPS Server Synchronize.ps1
NPS Server Synchronize.ps1
###Network Policy Server Synchronization Script #This script copies the configuration from the NPS Master Server and imports it on this server. #The Account that this script runs under must have Local Administrator rights to the NPS Master. #This was designed to be run as a scheduled task on the NPS Secondary Server...
PowerShellCorpus/PoshCode/Start-Countdown.ps1
Start-Countdown.ps1
function Start-Countdown{ <# .Synopsis Initiates a countdown on your session. Can be used instead of Start-Sleep. Use case is to provide visual countdown progress during "sleep" times .Example Get-Countdown -Seconds 10 This method will clear the screen and display descending seconds .Exam...
PowerShellCorpus/PoshCode/List Object Discoveries.ps1
List Object Discoveries.ps1
# Enumerate OpsMgr 2007 Object Discoveries targeted to Windows Server # Date: 13/10/2008 # Author: Stefan Stranger (help from Jeremy Pavleck and Marco Shaw) get-discovery |? {$_.Target -match (get-monitoringclass | where {$_.Name -eq "Microsoft.Windows.Server.Computer"}).Id} | select Name, DisplayName
PowerShellCorpus/PoshCode/Compare Table & DataRow_1.ps1
Compare Table & DataRow_1.ps1
function Compare-DataRow { param( $a, $b) # @bernd_k http://pauerschell.blogspot.com/ $diff = '' $a_columncount = $a.Table.columns.count $b_columncount = $b.Table.columns.count if ( $a_columncount -ne $b_columncount) { Write-host "Tables have different numbe...
PowerShellCorpus/PoshCode/Lock close button.ps1
Lock close button.ps1
$code = @' using System; using System.Runtime.InteropServices; namespace CloseButtonToggle { internal static class WinAPI { [DllImport("kernel32.dll")] internal static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static e...
PowerShellCorpus/PoshCode/Move-Template.ps1
Move-Template.ps1
#requires -version 2.0 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 ...
PowerShellCorpus/PoshCode/Get-LastBootUpTime.ps1
Get-LastBootUpTime.ps1
<# .SYNOPSIS Gets the start time of the PC .DESCRIPTION The Get-LastBootUpTime function returns an LBUT object that represents the time the computer started. You can use Get-LabstBootUpTime to generate the up time of a PC. By default it uses EventID 6005 from the System log to determine when the PC started....
PowerShellCorpus/PoshCode/Execute-SQLCommand.ps1
Execute-SQLCommand.ps1
function Execute-SQLCommand {param( [string]$Server, #the host name of the SQL server [string]$Database, #the name of the database [System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure) $sqlConnection = New-Object System.Data.SqlClient.SqlCo...
PowerShellCorpus/PoshCode/Out-AnsiGraph.ps1
Out-AnsiGraph.ps1
# # Out-AnsiGraph.psm1 # Author: xcud # History: # v0.1 September 21, 2009 initial version # # PS Example> ps | select -first 5 | sort -property VM | Out-AnsiGraph ProcessName, VM # AEADISRV &#9608;&#9608;&#9608; 14508032 # audiodg &#9608;&#9608;&#9608;&#9608;&#9608;...
PowerShellCorpus/PoshCode/Set-PSODefaultProperties.ps1
Set-PSODefaultProperties.ps1
function Set-PSODefaultProperties { param( [PSObject]$Object, [string[]]$DefaultProperties ) if( $DefaultProperties -ne $null ) { $name = $Object.PSObject.TypeNames[0] $xml = "<?xml version='1.0' encoding='utf-8' ?><Types><Type>" ...
PowerShellCorpus/PoshCode/Services Auto NotRunning.ps1
Services Auto NotRunning.ps1
Get-WmiObject Win32_Service -ComputerName . |` where {($_.startmode -like "*auto*") -and ` ($_.state -notlike "*running*")}|` select DisplayName,Name,StartMode,State|ft -AutoSize
PowerShellCorpus/PoshCode/InkScape utilities.ps1
InkScape utilities.ps1
<# .SYNOPSIS Inkscape utility cmdlets MIT License Copyright (c) 2012-2013 Justin Dearing <zippy1981@gmail.com> 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, inclu...
PowerShellCorpus/PoshCode/SynchronizationScript.ps.ps1
SynchronizationScript.ps.ps1
#------- Get-SPServiceContext function Get-SPServiceContext([Microsoft.SharePoint.Administration.SPServiceApplication]$profileApp) { if($profileApp -eq $null) { #----- Get first User Profile Service Application $profileApp = @(Get-SPServiceApplication | ? { $_.TypeName -eq "User Profile ...
PowerShellCorpus/PoshCode/Get-CInfo_1.ps1
Get-CInfo_1.ps1
function Get-CInfo { param($Comp) Function PC-Name{ param ($compname) $ADS = Get-ADComputer -Filter {name -eq $compname} -Properties * | Select-Object -Property name If($ads -eq $null) {$false} ELSE{$True} } $ping = PC-Name $COMP if ($ping -eq $true) { Write-Host -ForegroundColor G...
PowerShellCorpus/PoshCode/Get-PrivateKeyPath_1.ps1
Get-PrivateKeyPath_1.ps1
#requires -Version 2.0 # # Example 1: # Get-PrivateKeyPath CN=DO_NOT_TRUST_FiddlerRoot -StoreName My -StoreScope CurrentUser # Example 2: # Get-PrivateKeyPath D359ECDC338CFDDCE86DDDA99BE36286BAE2018A function Get-PrivateKeyPath { param ( [Parameter(Mandatory = $true, Position = 0)] [string] $Certifi...
PowerShellCorpus/PoshCode/BufferBox 3.1.ps1
BufferBox 3.1.ps1
#################################################################################################### ## This script is just a demonstration of some of the things you can do with the buffer ## in the default PowerShell host... it serves as a reminder of how much work remains on ## PoshConsole, and as an inspiration t...
PowerShellCorpus/PoshCode/Roll-Dice_1.ps1
Roll-Dice_1.ps1
# Roll-Dice.ps1 # Cody Bunch # ProfessionalVMware.com Begin { $rand = New-Object System.Random $dice = $rand.next(1,3) } Process { if ( $_ -isnot [VMware.VimAutomation.Types.Snapshot] ) { continue } if ($dice -gt 1) { $_ | Remove-Snapshot -Confirm:$false Write-Host "$_.Name OH NOES! Has been del...
PowerShellCorpus/PoshCode/Terminate process _ user.ps1
Terminate process _ user.ps1
#Ty Lopes - Calgary - Oct 2012 #(Troy is a huge nerd) #How to kill a process by username #Originally created for a script (running under a sched task) that was not closing excel application after enumerating throught the excel file #Powershell does not seem to close excel properly using the workbook.close functio...
PowerShellCorpus/PoshCode/Get-HotFix.ps1
Get-HotFix.ps1
# The Get-HotFix function gets the quick-fix engineering (QFE) updates that have been applied to the local computer or to remote computers and filter those hotfixes named "file 1". # There is Get-HotFix cmdlet in PowerShell V2. This is an attempt to bring similar functionality to V1. function Get-HotFix { param (...
PowerShellCorpus/PoshCode/Boots DataGrid Binding.ps1
Boots DataGrid Binding.ps1
#load boots# Import-Module Powerboots function Export-NamedControl { [CmdletBinding()] param( [Parameter(ValueFromPipeline=$true, Position=1, Mandatory=$true)] $Root = $BootsWindow ) process { Invoke-BootsWindow $Root { $control = $BootsWindow while($control) { $control = $...
PowerShellCorpus/PoshCode/Findup_8.ps1
Findup_8.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/sample format file.ps1
sample format file.ps1
## UI Automation v 1.8 -- REQUIRES the Reflection module (current version: http://poshcode.org/3174 ) ## # WASP 2.0 is getting closer, but this is still just a preview: # -- a lot of the commands have weird names still because they're being generated ignorantly # -- eg: Invoke-Toggle.Toggle and Invoke-Invoke.Invo...
PowerShellCorpus/PoshCode/New-RssFeed.ps1
New-RssFeed.ps1
# Creates an RSS feed # Parameter input is for "site": Path, Title, Url, Description # Pipeline input is for feed items: hashtable with Title, Link, Author, Description, and pubDate keys param ( $Path = "$( throw 'Path is a mandatory parameter.' )", $Title = "Site Title", $Url = "http://$( $env:computername )"...
PowerShellCorpus/PoshCode/Sort IE Favorites_1.ps1
Sort IE Favorites_1.ps1
$Results = gci $env:userprofile\\favorites -rec -inc *.url | ? {select-string -inp $_ -quiet "^URL=http"} | select @{Name="Name"; Expression={[IO.Path]::GetFileNameWithoutExtension($_.FullName)}}, @{Name="URL"; Expression={get-content $_ | ? {$_ -match "^URL=http"} | % {$_.Substring(4)}}} New-Item $env:userprofil...
PowerShellCorpus/PoshCode/Get_Set Signature (CTP3)_1.ps1
Get_Set Signature (CTP3)_1.ps1
#Requires -version 2.0 ## Authenticode.psm1 updated for CTP 3 #################################################################################################### ## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets ## These properly parse paths, so they don't kill your pipeline and ...
PowerShellCorpus/PoshCode/88c1a7d6-0bf3-48db-bec5-4b21531648c5.ps1
88c1a7d6-0bf3-48db-bec5-4b21531648c5.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/Product key_1.ps1
Product key_1.ps1
from System import Array, Char, Console from System.Collections import ArrayList from Microsoft.Win32 import Registry def DecodeProductKey(digitalProductID): map = ("BCDFGHJKMPQRTVWXY2346789").ToCharArray() key = Array.CreateInstance(Char, 29) raw = ArrayList() i = 52 while i < 67: raw...
PowerShellCorpus/PoshCode/Show-Image.ps1
Show-Image.ps1
function Show-Image { param([string]$file = $(throw "No file specified.")) [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void][Reflection.Assembly]::LoadWithPartialName("System.Drawing") #maybe this idea is not good but it can help display big images [Windows.Forms.Screen]...
PowerShellCorpus/PoshCode/Export-PSCredential_4.ps1
Export-PSCredential_4.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/Balance-Datastores_1.ps1
Balance-Datastores_1.ps1
<# TODO -Change number of DSTs to is selection of $DSTMostFree to be variable. Also add in logic to select DSTs with lower VMCounts. Total DSTs Select DSTs ---------- ----------- <5 1 5-20 3 >20 5 -For $DSTLeastFree add in logic to select DSTs with higher VMCounts...
PowerShellCorpus/PoshCode/Correction.ps1
Correction.ps1
function Convert-ToCHexString { [CmdletBinding()] param ( [Parameter(ValueFromPipeline=$true,Mandatory=$true)][string]$str ) @@ process { ($str.ToCharArray() | %{ "0x{0:X2}" -f [int]$_ }) -join ',' } }
PowerShellCorpus/PoshCode/VM Disk Report_2.ps1
VM Disk Report_2.ps1
$VMs = get-vm $Results = @() foreach ($VM in $VMs) { $Result = new-object PSObject $Result | add-member -membertype NoteProperty -name "Name" -value $VM.Name $Result | add-member -membertype NoteProperty -name "Description" -value $VM.Notes $VMDiskCount = 1 get-harddisk $VM | foreach { ...
PowerShellCorpus/PoshCode/65b30476-81de-4034-8d3c-ef5e8bdd0e43.ps1
65b30476-81de-4034-8d3c-ef5e8bdd0e43.ps1
$url = "http://dougfinke.com/scriptinggames/scriptinggames.html" $web = New-Object System.Net.WebClient foreach($line in ($web.downloadString($url)).split("`n")){ if($line -match "img"){ $line $fileName = $line.substring($line.indexof("title=")+7,(($line.indexof(" src"))-1)-($line.indexof("t...
PowerShellCorpus/PoshCode/Remove-FTPFile.ps1
Remove-FTPFile.ps1
function Remove-FTPFile ($Source,$UserName,$Password) { #Create FTP Web Request Object to handle connnection to the FTP Server $ftprequest = [System.Net.FtpWebRequest]::Create($Source) # set the request's network credentials for an authenticated connection $ftprequest.Credentials = New-Object System.N...