full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/BridgeBot 1.0.ps1
BridgeBot 1.0.ps1
## Depends on the PoshXmpp.dll from http://CodePlex.com/PowerXmpp #requires -pssnapin PoshXmpp ## Requires System.Web for the RSS-feed option [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null ########################################################################################## # @Author: Joe...
PowerShellCorpus/PoshCode/VMware and NetApp file f.ps1
VMware and NetApp file f.ps1
Add-PSSnapin VMware.VimAutomation.Core Import-Module DataOntap $cred = Get-VICredentialStoreItem -Host nau-vc.naucom.com -File c:\\users\\aaworkman\\powershell\\credentials.xml Connect-VIServer nau-vc -User $cred.User -Password $cred.Password $esxhost = "fargo-esx2.naucom.com" $numberofclones = 10 $loc = Get-Fo...
PowerShellCorpus/PoshCode/Import-Certificate_1.ps1
Import-Certificate_1.ps1
function Import-Certificate { param ( [IO.FileInfo] $CertFile = $(throw "Paramerter -CertFile [System.IO.FileInfo] is required."), [string[]] $StoreNames = $(throw "Paramerter -StoreNames [System.String] is required."), [switch] $LocalMachine, [switch] $CurrentUser, [string] $CertPassword, [switc...
PowerShellCorpus/PoshCode/Check Modules path_2..ps1
Check Modules path_2..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/Find-String_2.ps1
Find-String_2.ps1
<# .Synopsis Searches text files by pattern and displays the results. .Description Searches text files by pattern and displays the results. .Notes Based on versions from http://weblogs.asp.net/whaggard/archive/2007/03/23/powershell-script-to-find-strings-and-highlight-them-in-the-output.aspx and from http://pos...
PowerShellCorpus/PoshCode/Write-Log.ps1
Write-Log.ps1
function Write-Log { #region Parameters [cmdletbinding()] Param( [Parameter(ValueFromPipeline=$true,Mandatory=$true)] [ValidateNotNullOrEmpty()] [string] $Message, [Parameter()] [ValidateSet(“Error”, “Warn”, “Info”)] [string] $Level = “Info”, [Parameter()] [ValidateRange(1,30)] ...
PowerShellCorpus/PoshCode/Wake-OrphanedVMHost.ps1
Wake-OrphanedVMHost.ps1
#requires -pssnapin VMware.VimAutomation.Core # http://get-admin.com/blog/?p=342 #Get any cluster that has DPM Enabled $Clusters = @() $Clusters += Get-Cluster -verbose:$false | Where-Object { (Get-View -VIObject $_ -verbose:$false).ConfigurationEx.DpmConfigInfo.Enabled } Write-Verbose "$(get-date -uformat %T) Fo...
PowerShellCorpus/PoshCode/104237c9-a8e9-419e-b285-638b60444a56.ps1
104237c9-a8e9-419e-b285-638b60444a56.ps1
# by @bernd_k aka @sqlsulidae http://sqlsulidae.blogspot.com/ # # This is an extension of the script you find at # http://www.sqlmusings.com/2009/08/21/sql-server-powershell-how-to-view-your-ssrs-reports-rdl-using-powershell-and-reportviewer/ # I show ...
PowerShellCorpus/PoshCode/7fb49cb3-a349-4afb-ac39-1027dd643188.ps1
7fb49cb3-a349-4afb-ac39-1027dd643188.ps1
function Get-Parameter { [OutputType('System.String')] [CmdletBinding()] param( [Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)] [String]$Command, [Parameter(Position=1)] [String[]]$Name=@('*'), [Parameter()] [ValidateSet('Name','Type','Pos','BV','...
PowerShellCorpus/PoshCode/Set-Domain_1.ps1
Set-Domain_1.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-AvaDomain -domain corp.avanade.org -credential `$cred`n" ...
PowerShellCorpus/PoshCode/scriptable telnet client_1.ps1
scriptable telnet client_1.ps1
@@function read-stream ([Parameter(Posistion=0,Mandatory=$true)][validatenotnull()] [System.Net.Sockets.NetworkStream]$stream, [String]$expect = "") { $buffer = new-object system.byte[] 1024 $enc = new-object system.text.asciiEncoding ## Read all the data available from the stream, writing it to the #...
PowerShellCorpus/PoshCode/Get-StaticMethodDefin.ps1
Get-StaticMethodDefin.ps1
#Steven Murawski #http://blog.usepowershell.com #03/20/2009 function Get-StaticMethodDefinition() { param ($Method, [Type]$Type=$null) BEGIN { if ($Type -ne $null) { $Type | Get-StaticMethodDefinition $Method } } PROCESS { if ($_ -ne $null) { $_ | Get-Member -Name $Method -St...
PowerShellCorpus/PoshCode/VMtoolsUpgrade-disable_2.ps1
VMtoolsUpgrade-disable_2.ps1
##################################################################### # 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 # 2. Execute script from PowerCLI # 3. Enter...
PowerShellCorpus/PoshCode/Set-Computername_2.ps1
Set-Computername_2.ps1
function Set-ComputerName { param( [switch]$help, @@ [string]$originalPCName=$(read-host "Please specify the current name of the computer"), [string]$computerName=$(read-host "Please specify the new name of the computer")) @@ $usage = "set-ComputerName -originalPCname CurrentName -computername AnewName" ...
PowerShellCorpus/PoshCode/Log4Net.xslt.ps1
Log4Net.xslt.ps1
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2" version="1.0"> <xsl:output method="html" indent="yes" encoding="US-ASCII"/> <xsl:temp...
PowerShellCorpus/PoshCode/chkhash_7.ps1
chkhash_7.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/Manual DNS Scavenging.ps1
Manual DNS Scavenging.ps1
#========================================================================== # # PowerShell Source File # # AUTHOR: Stephen Wheet # NAME: dnsscavenge.ps1 # Version: 1.2 # Date: 8/12/10 # # COMMENT: # This script was created to manually scavenge DNS records for a given # period. Specify the date of last r...
PowerShellCorpus/PoshCode/Netapp SDK.ps1
Netapp SDK.ps1
#Jason Ochoa 9/16/09 #Set up NaServerObject $null = [reflection.assembly]::loadfile('C:\\DotNet\\ManageOntap.dll') $Toaster1 = new-Object netapp.manage.naserver('Toaster1',1,0) $Toaster1.setadminuser("admin",'password') #-------------------functions to be remade function global:Get-DF-s ($NaServer){#this data...
PowerShellCorpus/PoshCode/chkhash_27.ps1
chkhash_27.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/Dir for days.ps1
Dir for days.ps1
#Initialize Global Variables $NumYears = 0 $NumMonths = 0 $NumDays = 0 $LeapYearTest = 0 $FirstDate = '' $LastDate = '' $LastDateFeb = '' $destination = Join-Path $env:USERPROFILE '\\Desktop\\Export Data' #Tells program where to write directory structure #Get the first date from user $FirstDate = Read-host ...
PowerShellCorpus/PoshCode/chkhash_2.ps1
chkhash_2.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/Get_Set Signature _2.0.ps1
Get_Set Signature _2.0.ps1
#Requires -version 2.0 ## Authenticode.psm1 updated for PowerShell 2.0 (with time stamping) #################################################################################################### ## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets ## These properly parse paths, so they...
PowerShellCorpus/PoshCode/Reflection Module.ps1
Reflection Module.ps1
#requires -version 2.0 #History: # 1.0 - First public release (March 19, 2010) # 2.0 - Private Build # - Included the Accelerator function inline # - Added a few default aliases # 3.0 - September 3, 2010 # - Included the New-ConstructorFunction feature (ripped from PowerBoots to serve a more ge...
PowerShellCorpus/PoshCode/ESX Lun Latencies.ps1
ESX Lun Latencies.ps1
function Get-VMHostLunLatency { param($VMHost) $luns = $VMHost | Get-ScsiLun foreach ($lun in $luns) { $stats = $VMHost | Get-Stat -stat disk.totalreadlatency.average,disk.totalwritelatency.average -maxsamples 1 -realtime | Where { $_.Instance -eq $Lun.CanonicalName } if ($stats.length -ne $null) ...
PowerShellCorpus/PoshCode/DHCP Backup_1.ps1
DHCP Backup_1.ps1
Import-Module ActiveDirectory param ( [Parameter(Position=1)] $searchBase = "cn=configuration,dc=domain,dc=com", [Parameter(Position=2)] $backupDestRoot = "\\\\network\\share\\" ) function Get-OnlineDhcpServers { param ( [Parameter(Mandatory=$true,Position=1)] $dhcpSear...
PowerShellCorpus/PoshCode/Find Installed .NET ver.ps1
Find Installed .NET ver.ps1
# Svendsen Tech's .Net version finding script. # See the full documentation at: # http://www.powershelladmin.com/wiki/Script_for_finding_which_dot_net_versions_are_installed_on_remote_workstations param([Parameter(Mandatory=$true)][string[]] $ComputerName, [switch] $Clobber) ##### START OF FUNCTIONS ####...
PowerShellCorpus/PoshCode/Get-PSPVersion.ps1
Get-PSPVersion.ps1
$ServerInstance = "YourCMSServerInstance" $query = @" SELECT DISTINCT s.name FROM msdb.dbo.sysmanagement_shared_registered_servers s JOIN msdb.dbo.sysmanagement_shared_server_groups g ON s.server_group_id = g.server_group_id "@ $servers = sqlcmd -S "$ServerInstance" -d "master" -Q "SET NOCOUNT ON; $query" -h -...
PowerShellCorpus/PoshCode/1dd696a1-0d97-40cd-9cdf-5cbe5b7fe4a4.ps1
1dd696a1-0d97-40cd-9cdf-5cbe5b7fe4a4.ps1
function Write-Host { <# .SYNOPSIS Replacement of Write-Host function to work around an issue where use of Write-Host can cause an eventual problem with launching EXEs from within the same Powershell session. .DESCRIPTION This Write-Host replacement can act as a temporary wo...
PowerShellCorpus/PoshCode/Office 365 wasted Lics.ps1
Office 365 wasted Lics.ps1
$AD = 'C:\\temp\\ad.csv' $o365 = 'C:\\temp\\o365.csv' $duplicates = 'C:\\temp\\Duplicate Office 365 users.csv' $log = 'C:\\temp\\Duplicate Office 365 users.log' $PSEmailServer = 'MAILSERVER' $EmailTo = 'TO-EMAILADDRESS' $EmailFrom = 'FROM-EMAILADDRESS' Import-Module ActiveDirectory Import-Module MSOnline ...
PowerShellCorpus/PoshCode/New-PSOCustomObject.ps1
New-PSOCustomObject.ps1
# References: # http://blogs.msdn.com/powershell/archive/2009/12/05/new-object-psobject-property-hashtable.aspx # http://poshoholic.com/2008/07/03/essential-powershell-name-your-custom-object-types/ # http://poshoholic.com/2008/07/05/essential-powershell-define-default-properties-for-custom-objects/ function New-...
PowerShellCorpus/PoshCode/c439471e-f811-4037-9472-dde03db24534.ps1
c439471e-f811-4037-9472-dde03db24534.ps1
$WarningPreference = "SilentlyContinue" $password = Get-Content C:\\securestring.txt | convertto-securestring $username = "PROD\\administrator" $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password $uucenter = "uu-lillebaelt.dk" $totalSize = 0 $sessio...
PowerShellCorpus/PoshCode/Get-ExchangeDBSizes_3.ps1
Get-ExchangeDBSizes_3.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/New-ISEMenu_2.ps1
New-ISEMenu_2.ps1
Import-Module ShowUI Function New-ISEMenu { New-Grid -AllowDrop:$true -Name "ISEAddonCreator" -columns Auto, * -rows Auto,Auto,Auto,*,Auto,Auto -Margin 5 { New-Label -Name Warning -Foreground Red -FontWeight Bold -Column 1 ($target = New-TextBox -Name txtName -Column 1 -Row ($Row=1)) New-Label...
PowerShellCorpus/PoshCode/Get-ExcludedCsprojJavasc.ps1
Get-ExcludedCsprojJavasc.ps1
param( $projectDirectoryName = "MyProject" ) $thisDir = Split-Path $MyInvocation.MyCommand.Path $projectDir = "$thisDir/../$projectDirectoryName" $csproj = [xml](cat $projectDir/*.csproj) $csprojScripts = $csproj.Project.ItemGroup.Content.Include | ? {$_ -match '\\.js$'} "$($csprojScripts.length) scrip...
PowerShellCorpus/PoshCode/Get-WebFile _1.7.3.ps1
Get-WebFile _1.7.3.ps1
## Get-WebFile (aka wget for PowerShell) ############################################################################################################## ## Downloads a file or page from the web ## History: ## v3.7.3 - Checks to see if URL is formatted properly (contains http or https) ## v3.7.2 - Puts a try-catch b...
PowerShellCorpus/PoshCode/Email-ExpiringADAccounts_1.ps1
Email-ExpiringADAccounts_1.ps1
Function GetMsgBody { Write-Output @" <p>Dear $name,</p> Your ABC network account is about to expire.<br/> Please email helpdesk@abc.com or simply hit 'reply', and include the following details to have your account extended.<br/> <br/> Your name:<br/> The department you currently volunteer in:<br/> ...
PowerShellCorpus/PoshCode/Add new smtp_set prmary_1.ps1
Add new smtp_set prmary_1.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/Set-Computername_7.ps1
Set-Computername_7.ps1
function Set-ComputerName { param( [switch]$help, [string]$originalPCName=$(read-host "Please specify the current name of the computer"), [string]$computerName=$(read-host "Please specify the new name of the computer")) $usage = "set-ComputerName -originalPCname CurrentName -computername AnewName" if (...
PowerShellCorpus/PoshCode/Enable_Disable FusionLog.ps1
Enable_Disable FusionLog.ps1
function global:Enable-FusionLog { Remove-ItemProperty HKLM:Software\\Microsoft\\Fusion -name EnableLog -ErrorAction SilentlyContinue [void](New-ItemProperty HKLM:Software\\Microsoft\\Fusion -name EnableLog -propertyType dword -ErrorAction Stop) Set-ItemProperty HKLM:Software\\Microsoft\\Fusion -...
PowerShellCorpus/PoshCode/Interact with in-VM UI.ps1
Interact with in-VM UI.ps1
# First, start asynchronous tools update. We need to do it in a separate process # because the update is a beta version which contains unsigned drivers and will # be blocked by Windows' driver confirmation prompt $updateScript = " Add-PSSnapin VMware.VimAutomation* Connect-VIServer $DefaultVIServer Get-VM 'OldVMT...
PowerShellCorpus/PoshCode/New-AdUserAccount.ps1
New-AdUserAccount.ps1
function New-AdUserAccount {     param (         [string] $Username = $(throw "Parameter -Username [System.String] is required."),         [string] $Password = $(throw "Parameter -Password [System.String] is required."),         [string] $OrganizationalUnit = "Users",         [string] $DisplayName,         [str...
PowerShellCorpus/PoshCode/5d8d9270-3bf2-4dc4-8257-653fd32f8a8c.ps1
5d8d9270-3bf2-4dc4-8257-653fd32f8a8c.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-Domain -domain MyDomain -credential `$cred`n" if ($hel...
PowerShellCorpus/PoshCode/Get-GroupMembership_4.ps1
Get-GroupMembership_4.ps1
## Get-DistinguishedName -- look up a DN from a user's (login) name function Get-DistinguishedName { Param($UserName) $ads = New-Object System.DirectoryServices.DirectorySearcher([ADSI]'') $ads.filter = "(&(objectClass=Person)(samAccountName=$UserName))" $s = $ads.FindOne() return $s.GetDirectoryEnt...
PowerShellCorpus/PoshCode/Pivot-Object_1.ps1
Pivot-Object_1.ps1
#.Synopsis # Pivot multiple objects which are normalized with properties that are name, value pairs. #.Description # Takes a series of objects where there are multiple rows to represent each object, with a pair of columns with the name and value of an additional property, and outputs new objects which have those ...
PowerShellCorpus/PoshCode/List AD Users CSV.ps1
List AD Users CSV.ps1
$NumDays = 0 $LogDir = ".\\User-Accounts.csv" $currentDate = [System.DateTime]::Now $currentDateUtc = $currentDate.ToUniversalTime() $lltstamplimit = $currentDateUtc.AddDays(- $NumDays) $lltIntLimit = $lltstampLimit.ToFileTime() $adobjroot = [adsi]'' $objstalesearcher = New-Object System.DirectoryServices.Dire...
PowerShellCorpus/PoshCode/Audit Script_3.ps1
Audit Script_3.ps1
##################################################### # # # Audit script by Alan Renouf - Virtu-Al # # Blog: http://teckinfo.blogspot.com/ # # # # Usage: Audit.ps1 'pathtolistofservers' # # # # The file is optional and needs to be a # ...
PowerShellCorpus/PoshCode/TabExpansion for V2CTP_8.ps1
TabExpansion for V2CTP_8.ps1
## Tab-Completion ################# ## For V2CTP3. ## This won't work on V1 and V2CTP and V2CTP2. ## 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...
PowerShellCorpus/PoshCode/Set-Proxy_1.ps1
Set-Proxy_1.ps1
param( [Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)] [alias("Name","ComputerName")] $Computer = @($env:computername), [switch] $ClearProxy ) begin{ $IEsettingsKey = ".DEFAULT\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" [array]$ProxyResult = @() f...
PowerShellCorpus/PoshCode/Compare-InstalledHotfix.ps1
Compare-InstalledHotfix.ps1
Function Compare-InstalledHotfix { param ( [parameter(Mandatory=$true,Position=0)] $server1, [parameter(Mandatory=$true,Position=1)] $server2, [parameter(Mandatory=$true,Position=3)] [Management.Automation.PSCredential] $credential ) $server1HotFix = get-hotfix -computer $server1 -Credential $credentia...
PowerShellCorpus/PoshCode/Test-Hash.ps1
Test-Hash.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/Get MOSS User Profile_1.ps1
Get MOSS User Profile_1.ps1
function Get-UserProfile($accountName) { [reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null [reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server") | out-null $upm =[Microsoft.Office.Server.UserProfiles.UserProfileManager]( [Microsoft.Office.Server.ServerContext]::D...
PowerShellCorpus/PoshCode/ACE.psm1.ps1
ACE.psm1.ps1
####################### function Get-ACEConnection { param($ConnectionString) $conn = new-object System.Data.OleDb.OleDbConnection($ConnectionString) $conn.open() $conn } #Get-ACEConnection ####################### function Get-ACETable { param($Connection) ...
PowerShellCorpus/PoshCode/Compare-DataSources.ps1
Compare-DataSources.ps1
#Define DPMHosts [CmdletBinding()] param([string]$PrimaryDPMHost, [string]$SecondaryDPMHost); Write-Verbose "Compare-DataSources.ps1 written by Shai Perednik sperednik@deloitte.com" Write-Verbose "Primary DPM Host: $PrimaryDPMHost" Write-Verbose "Secondary DPM Host: $SecondaryDPMHost" #Load DPM Snaping Write...
PowerShellCorpus/PoshCode/Password Generator Form.ps1
Password Generator Form.ps1
Function Create-Password { #How many characters in the password [int]$passwordlength = 14 ##Make sure that number of characters below are not greater than $passwordlength!! #Minimum Upper Case characters in password [int]$min_upper = 3 ...
PowerShellCorpus/PoshCode/Build-TFSProjects.ps1
Build-TFSProjects.ps1
#------------------------------------------------------------------------- # Script that will: # 1. Create a workspace. Workspacce Name: _Root # 2. Get the latest code from repository #------------------------------------------------------------------------- Param( [switch] $CSRWEB, [switch]...
PowerShellCorpus/PoshCode/Select-Random v2.1.ps1
Select-Random v2.1.ps1
# --------------------------------------------------------------------------- ### <Script> ### <Author> ### Joel "Jaykul" Bennett ### </Author> ### <Description> ### Selects a random element from the collection either passed as a parameter or input via the pipeline. ### If the collection is passed in as an argum...
PowerShellCorpus/PoshCode/Invoke-SqlCmd_2.ps1
Invoke-SqlCmd_2.ps1
function Invoke-Sqlcmd2 { param( [string]$ServerInstance, [string]$Database, [string]$Query, [Int32]$QueryTimeout=30 ) $conn=new-object System.Data.SqlClient.SQLConnection $conn.ConnectionString="Server={0};Database={1};Integrated Security=True" -f $ServerInstance,$Database ...
PowerShellCorpus/PoshCode/Time-Stamp.ps1
Time-Stamp.ps1
function Time-Stamp { return [System.DateTime]::Now.ToString("yyyy.MM.dd hh:mm:ss"); } New-Alias -Name ts -Value Time-Stamp;
PowerShellCorpus/PoshCode/Compare-Property.ps1
Compare-Property.ps1
##############################################################################\n##\n## Compare-Property\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\nCompare...
PowerShellCorpus/PoshCode/test_3.ps1
test_3.ps1
[CmdletBinding()] param() "This file is in the $PSScriptRoot folder."
PowerShellCorpus/PoshCode/Get-ADNonExpPass.ps1
Get-ADNonExpPass.ps1
param ($LDAPPath = "", [switch]$Help) if ($Help) { "" Write-Host "Usage: .\\Get-ADNonExpPass.ps1 <LDAPPath>" -foregroundcolor Yellow Write-Host "Ex: .\\Get-ADNonExpPass.ps1 'LDAP://ou=users,dc=domain,dc=com'" -foregroundcolor Yellow "" break } #UAC Flag in Hex #http://support.microsoft.com/kb/30514...
PowerShellCorpus/PoshCode/Get-OLEDBData_2.ps1
Get-OLEDBData_2.ps1
########################################################################### # Get-OLEDBData # -------------------------------------------- # Description: This function is used to retrieve data via an OLEDB data # connection. # # Inputs: $connectstring - Connection String. # $sql ...
PowerShellCorpus/PoshCode/ConvertTo-DN_1.ps1
ConvertTo-DN_1.ps1
#Author: Glenn Sizemore glnsize@get-admin.com # #Purpose: Convert a DN to a Canonical name, and back again. # #Example: PS > ConvertFrom-Canonical 'get-admin.local/test/test1/Sizemore, Glenn E' # CN=Sizemore\\, Glenn E,OU=test1,OU=test,DC=getadmin,DC=local # PS > ConvertFrom-DN 'CN=Sizemore\\, Glenn E,OU=t...
PowerShellCorpus/PoshCode/Get-MacAddressOui.ps1
Get-MacAddressOui.ps1
function Get-MacAddressOui { <# .SYNOPSIS Gets a MAC address OUI (Organizationally Unique Identifier). .DESCRIPTION The Get-MacAddressOui function retrieves the MAC address OUI reference list maintained by the IEEE standards website and returns the name of the company to which the MAC address OUI is ass...
PowerShellCorpus/PoshCode/chkhash_21.ps1
chkhash_21.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/CertMgmt pack_3.ps1
CertMgmt pack_3.ps1
##################################################################### # CertMgmtPack.ps1 # Version 0.51 # # Digital certificate management pack # # Vadims Podans (c) 2009 # http://www.sysadmins.lv/ ##################################################################### #requires -Version 2.0 function Import-C...
PowerShellCorpus/PoshCode/Aero Glass PowerShell.ps1
Aero Glass PowerShell.ps1
#requires -version 2 param([switch]$Disable) add-type -namespace Hacks -name Aero -memberdefinition @" [StructLayout(LayoutKind.Sequential)] public struct MARGINS { public int left; public int right; public int top; public int bottom; } [DllImport("d...
PowerShellCorpus/PoshCode/Convert Raw SID to SID_1.ps1
Convert Raw SID to SID_1.ps1
#For intel concerning how to convert raw hex SID to Standard SID got to #http://blogs.msdn.com/b/oldnewthing/archive/2004/03/15/89753.aspx #to convert Hex to Dec function Convert-HEXtoDEC { param($HEX) ForEach ($value in $HEX) { [string][Convert]::ToInt32($value,16) } } #to reassort decimal values to co...
PowerShellCorpus/PoshCode/Start-ProcessAsUser.ps1
Start-ProcessAsUser.ps1
##############################################################################\n##\n## Start-ProcessAsUser\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\nLaun...
PowerShellCorpus/PoshCode/Get-WebSite_7.ps1
Get-WebSite_7.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/ExecutePowerShell.cmd.ps1
ExecutePowerShell.cmd.ps1
:: <# copy %0 %0.ps1 PowerShell.exe -ExecutionPolicy Unrestricted -NoProfile -Command "$ErrorActionPreference = 'SilentlyContinue'; . %0.ps1; Remove-Item %0.ps1" exit :: #> $ErrorActionPreference = 'Continue' ### Your PowerShell script goes below here. ### I've put a couple of lines as an example ... ls | sor...
PowerShellCorpus/PoshCode/Get-User_4.ps1
Get-User_4.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/Set-Domain_2.ps1
Set-Domain_2.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-AvaDomain -domain corp.avanade.org -credential `$cred`n" ...
PowerShellCorpus/PoshCode/Migrate UserFolder_1.ps1
Migrate UserFolder_1.ps1
param( $RootFolder = "\\\\domain.local\\users", $NewRootFolder = "\\\\domain.local\\users2", $LogFolder = "c:\\Projects\\HomeDirs", $NewSubFolders = @("Documents","Favorites","Desktop","Links","Contacts","BlaBla"), [switch]$SetACL ) $UserFolders = gci -Path $RootFolder | ?{$_.PSIsContainer} $UserFolders | forea...
PowerShellCorpus/PoshCode/Test-WebDAV_2.ps1
Test-WebDAV_2.ps1
function Test-WebDav () { param ( $Url = "$( throw 'URL parameter is required.')" ) $xhttp = New-Object -ComObject msxml2.xmlhttp $xhttp.open("OPTIONS", $url, $false) $xhttp.send() if ( $xhttp.getResponseHeader("DAV") ) { $true } else { $false } }
PowerShellCorpus/PoshCode/Get-FileHash.ps1
Get-FileHash.ps1
##############################################################################\n##\n## Get-FileHash\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\nGet the has...
PowerShellCorpus/PoshCode/Findup_11.ps1
Findup_11.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/Get-ProcAddress.ps1
Get-ProcAddress.ps1
function Get-ProcAddress { <# .Synopsis Returns the address of the desired Windows API function. .Description The Get-ProcAddress function returns the address of the desired Windows API function. The technique used to get the address does not rely upon P/Invoke or compiling C# code. GetProcAddress can be acces...
PowerShellCorpus/PoshCode/Set Logfile length_5.ps1
Set Logfile length_5.ps1
<# .SYNOPSIS Set any text file to a fixed number of lines. Use 'Get-Help .\\SetFileLines -full' to view Help for this file. .DESCRIPTION This script will maintain the PS Transcript file (default setting), or any text file, at a fixed length, ie matching the number of lines entered. However, omitting the lines p...
PowerShellCorpus/PoshCode/Powershell iTunes_1.ps1
Powershell iTunes_1.ps1
# #***************************************************************** # # Powershell iTunes v1 $Rev: 754 $ # (c) 2004-2010 Thomas Maurer. All rights reserved. # created by Thomas Maurer # # http://www.thomasmaurer.ch # http://www.thomasmaurer.ch/projects # # last Update by $Author: tmaurer $ on $Date: 2010-11...
PowerShellCorpus/PoshCode/Deploy Folder .ps1
Deploy Folder .ps1
Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue #This is needed to pull computers from AD Clear-Host $Skipped = @() #Create Array for Skipped Computers $Finished = @() #Create Array for Finished Computers $Offline = @() #Create Array for Offline Computers $Computers = Get-QADComputer -Sea...
PowerShellCorpus/PoshCode/TabExpansion for V2CTP_7.ps1
TabExpansion for V2CTP_7.ps1
## Tab-Completion ################# ## For V2CTP3. ## This won't work on V1 and V2CTP and V2CTP2. ## 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...
PowerShellCorpus/PoshCode/Invoke-Generic_2.ps1
Invoke-Generic_2.ps1
function Invoke-Generic { #.Synopsis # Invoke Generic method definitions via reflection: [CmdletBinding()] param( [Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [Alias('On')] $InputObject , [Parameter(Position=1,ValueFromPipelineByPropertyName=$true)] [Alias('Na...
PowerShellCorpus/PoshCode/New-StoredProcFunction_1.ps1
New-StoredProcFunction_1.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/New-Shortcut_1.ps1
New-Shortcut_1.ps1
#requires -version 2.0 function New-Shortcut { <# .SYNOPSIS Creates a new shortcut (.lnk file) pointing at the specified file. .DESCRIPTION The New-Shortcut script creates a shortcut pointing at the target in the location you specify. You may specify the location as a folder path (which must exist), with a n...
PowerShellCorpus/PoshCode/set-localpwd.ps1
set-localpwd.ps1
# Sets local account passwords on one or more computers # usage [computerName1,computerName2,... | ] ./set-localpwd.ps1 [-user] <userName> [-password] <password> [[-computers] computerName1,computerName2,...] param( [string] $User , [string] $Password , [string[]] $ComputerNames = @() ) $ComputerNames ...
PowerShellCorpus/PoshCode/convert CSV_s to Excel.ps1
convert CSV_s to Excel.ps1
Function Release-Ref ($ref) { ([System.Runtime.InteropServices.Marshal]::ReleaseComObject( [System.__ComObject]$ref) -gt 0) [System.GC]::Collect() [System.GC]::WaitForPendingFinalizers() } Function ConvertCSV-ToExcel { <# .SYNOPSIS Converts one or more C...
PowerShellCorpus/PoshCode/finddupe_14.ps1
finddupe_14.ps1
# new version avoids recalculating MD5s, has delete/noprompt options, and by default checks the current directory. function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvide...
PowerShellCorpus/PoshCode/Hack ESXi_5.ps1
Hack ESXi_5.ps1
$screen = " You see here a virtual switch. ------------ ------ #...........| |....| --------------- ###------------ |...(| |..%...........|########## ###-@...| ...
PowerShellCorpus/PoshCode/9cae4b8c-e40a-43f0-8dea-dd78acab16c3.ps1
9cae4b8c-e40a-43f0-8dea-dd78acab16c3.ps1
[reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null [reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server") | out-null [reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") | out-null @@#NOTE: I've set strict crawl freshness/crawl duration/success rati...
PowerShellCorpus/PoshCode/Search-AD.ps1
Search-AD.ps1
# add enumerations and types required for functions Add-Type @' using System; namespace redtoo { namespace AD { public enum Provider : int { LDAP, GC, } } public class ADsPathPart { public string Provider; public string Server; ...
PowerShellCorpus/PoshCode/Set-WebConfig_2.ps1
Set-WebConfig_2.ps1
function Set-WebConfigSqlConnectionString { param( [switch]$help, [string]$configfile = $(read-host "Please enter a web.config file to read"), [string]$connectionString = $(read-host "Please enter a connection string"), [switch]$backup = $TRUE ) $usage = "`$conString = `"Data S...
PowerShellCorpus/PoshCode/Set-WindowTransparent.ps1
Set-WindowTransparent.ps1
## Set-WindowTransparent.ps1 ## ## Add-Type -Type @" using System; using System.Runtime.InteropServices; using System.Text; namespace TE { public static class Win32Methods { internal const int GWL_EXSTYLE = -20; internal const int WS_EX_LAYERED = 0x80000; internal const int LWA_ALPHA...
PowerShellCorpus/PoshCode/CreateVDS_2.ps1
CreateVDS_2.ps1
function CreateVDS( $vdsName, $datacenter, $vmHost, $physicalNic, $portGroupType = "earlyBinding", ` [array]$portGroupNameList = @(),[array]$uplinkList = @() ) { # ------- Create vDS ------- # $vdsCreateSpec = New-Object VMware.Vim.DVSCreateSpec $vdsCreateSpec.configSpec = New-Object VMware.V...
PowerShellCorpus/PoshCode/get windows product key_6.ps1
get windows product key_6.ps1
function get-windowsproductkey([string]$computer) { $Reg = [WMIClass] ("\\\\" + $computer + "\\root\\default:StdRegProv") $values = [byte[]]($reg.getbinaryvalue(2147483650,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion","DigitalProductId").uvalue) $lookup = [char[]]("B","C","D","F","G","H","J","K","M","P","Q","R"...
PowerShellCorpus/PoshCode/SyntaxHighlighter Brush.ps1
SyntaxHighlighter Brush.ps1
// /** * PowerShell 2.0 Brush for highlighter 2.0 * * SyntaxHighlighter http://alexgorbatchev.com/wiki/SyntaxHighlighter * * @version * 2.1.0 (April 07 2009) * * @copyright * Copyright (C) 2008-2009 Joel Bennett http://HuddledMasses.org/ * * @license * This file is for SyntaxHighlighter. ...
PowerShellCorpus/PoshCode/Get-WebSite_4.ps1
Get-WebSite_4.ps1
function Get-WebPage { <# .SYNOPSIS Downloads web page from site. .DESCRIPTION Downloads web page from site and displays source code or displays total bytes of webpage downloaded .PARAMETER Url URL of the website to test access to. .PARAMETER UseDefaultCredentials Use the currently authentica...
PowerShellCorpus/PoshCode/PS2WCF_2.ps1
PS2WCF_2.ps1
# Call WCF Services With PowerShell V1.0 22.12.2008 # # by Christian Glessner # Blog: http://www.iLoveSharePoint.com # Twitter: http://twitter.com/cglessner # Codeplex: http://codeplex.com/iLoveSharePoint # # requires .NET 3.5 # load WCF assemblies [void][System.Reflection.Assembly]::LoadWithPartialName("Sy...
PowerShellCorpus/PoshCode/DekiWiki Module 1.0.ps1
DekiWiki Module 1.0.ps1
## DekiWiki Module -note this is a v2 module, but I think you can dot-source in v1 if you remove the last line ;) #################################################################################################### ## The first of many script cmdlets for working with DekiWiki, based on their REST api sdk "Dream" ## ...
PowerShellCorpus/PoshCode/Format-TablePlus.ps1
Format-TablePlus.ps1
## Format-Table with wrapping and string trimming. function Format-TablePlus() { [CmdletBinding()] param( [Switch] ${AutoSize}, [Switch] ${HideTableHeaders}, [Switch] ${Wrap}, [Parameter(Position=0)] [System.Object[]] ${Property}, [System.Object] ${GroupBy}, ...