full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Find old snapshots.ps1 | Find old snapshots.ps1 | param ( $Age = 30 )
Connect-VIServer vcenter.domain.com
$vm = Get-VM
$snapshots = Get-Snapshot -VM $vm
Write-Host -ForegroundColor Red "Old snapshots found:"
foreach ( $snap in $snapshots ) {
if ( $snap.Created -lt (Get-Date).AddDays( -$Age ) ) {
Write-Host "Name: " $snap.Name " Size: " $snap.SizeMB " Cre... |
PowerShellCorpus/PoshCode/Get-Parameter 2.4.ps1 | Get-Parameter 2.4.ps1 | #Requires -version 2.0
#.Synopsis
# Enumerates the parameters of one or more commands
#.Notes
# With many thanks to Hal Rottenberg, Oisin Grehan and Shay Levy
# Version 0.80 - April 2008 - By Hal Rottenberg http://poshcode.org/186
# Version 0.81 - May 2008 - By Hal Rottenberg http://poshcode.org/255
# Ver... |
PowerShellCorpus/PoshCode/Get-MemoryChart_1.ps1 | Get-MemoryChart_1.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 http://poshcode.org/1003
# Uses the Tra... |
PowerShellCorpus/PoshCode/Get-DiskUsage_1.ps1 | Get-DiskUsage_1.ps1 | ##############################################################################\n##\n## Get-DiskUsage\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\nRetrieve i... |
PowerShellCorpus/PoshCode/Transparent Glass Posh.ps1 | Transparent Glass Posh.ps1 | #include <Misc.au3>
#include <Process.au3>
#Include <WinAPI.au3>
Opt("TrayIconHide",1)
Global Const $HSHELL_WINDOWCREATED = 1
Global Const $HSHELL_WINDOWACTIVATED = 4;
Global Const $HWND_MESSAGE = -3
Global $bHook = 1
$hGui = GUICreate("", 10, 10, -1, 0,-1,-1,$HWND_MESSAGE)
GUIRegisterMsg(_WinAPI_Registe... |
PowerShellCorpus/PoshCode/2c54f592-a435-48e1-9591-e9667f707941.ps1 | 2c54f592-a435-48e1-9591-e9667f707941.ps1 | <#
Name: VHDFunctions.psm1
Author: Rich Kusak (rkusak@cbcag.edu)
Created: 2009-10-23
LastEdit: 2009-11-02 15:54
Included Functions:
Dismount-VHD
Initialize-VHD
Mount-VHD
New-VHD
Set-VHDBootConfiguration
Test-VHD
#>
<#
.SYNOPSIS
Dismount a VHD file from the system.
.DESCRIPTION
This f... |
PowerShellCorpus/PoshCode/Logger_1.psm1 0.2.ps1 | Logger_1.psm1 0.2.ps1 | <#
Name : Universal Log4Net Logging Module (Logger.psm1)
Version : 0.3
Author : Joel Bennett (MVP)
Site : http://www.HuddledMasses.org/
Version History:
0.3 - Cleanupable release.
Added Udp, Email, Xml and RollingXml, as well as a "Chainsaw":http`://logging.apache.org/log... |
PowerShellCorpus/PoshCode/d25bbfc1-3d3f-42bb-a09e-67e69e89a865.ps1 | d25bbfc1-3d3f-42bb-a09e-67e69e89a865.ps1 | ###############################################################################
# Use Unregister-Event -SourceIdentifier <name> -Force (to stop an Event).
# Include script in $profile to register all these events. Modify to suit own
# requirements and comment out any of the examples below that are not needed.
# Pl... |
PowerShellCorpus/PoshCode/VMware Lab Manager 4.x.ps1 | VMware Lab Manager 4.x.ps1 | function Ignore-SslErrors {
# Create a compilation environment
$Provider=New-Object Microsoft.CSharp.CSharpCodeProvider
$Compiler=$Provider.CreateCompiler()
$Params=New-Object System.CodeDom.Compiler.CompilerParameters
$Params.GenerateExecutable=$False
$Params.GenerateInMemory=$True
$Params.IncludeDebugIn... |
PowerShellCorpus/PoshCode/Sync-Time_3.ps1 | Sync-Time_3.ps1 | function sync-time(
[string] $server = "sync-time 0.pool.ntp.org, clock.psu.edu",
[int] $port = 37)
{
$servertime = get-time -server $server -port $port -set
#leave off -set to just check the remote time
write-host "Server time:" $servertime
write-host "Local time :" $(date)
}
|
PowerShellCorpus/PoshCode/Save-CurrentFile (ISE).ps1 | Save-CurrentFile (ISE).ps1 | function Save-CurrentFile ($path)
{
$psISE.CurrentFile.SaveAs($path)
$psISE.CurrentFile.Save([Text.Encoding]::default)
}
# Save-CurrentFile '.\\Save-CurrentFile.ps1'
|
PowerShellCorpus/PoshCode/exclude properties_1.ps1 | exclude properties_1.ps1 | $server = "dcserver1.mafoberg.net"
$session = new-pssession -computer $server -cred $creds
icm -Session $session -ScriptBlock {
import-module activedirectory
(get-ADUser -filter "*" -properties GivenName, SurName, EmailAddress | select -ExcludeProperty PSComputerName, RunspaceId, PSShowComputerName )
... |
PowerShellCorpus/PoshCode/PoshCode ISE Addon.ps1 | PoshCode ISE Addon.ps1 | if (!(Get-Module WPK)) {Import-Module -global WPK}
if (!(Get-Module PoshCode)) {Import-Module -global PoshCode}
Function Get-PoshCodePreferences {
if (Get-Item $global:xmlPath -ErrorAction SilentlyContinue) {
try {
$pcPreferences = Import-Clixml -Path $global:xmlPath
$global:... |
PowerShellCorpus/PoshCode/JSON 1.1.ps1 | JSON 1.1.ps1 | #requires -version 2.0
# Version History:
# v 0.5 - First Public version
# v 1.0 - Made ConvertFrom-Json work with arbitrary JSON
# - switched to xsl style sheets for ConvertTo-JSON
# v 1.1 - Changed ConvertFrom-Json to handle single item results
# There is no help (yet) because I'm still changing and r... |
PowerShellCorpus/PoshCode/CapsLock Notifier.ps1 | CapsLock Notifier.ps1 | <#
.NOTES
Name : CapsLockNotifier.ps1
Author : Bryan Jaudon <bryan.jaudon@gmail.com>
Version : 1.0
Date : 10/25/2012
.Description
Adds a notification icon to show current CapsLock status. Double clicking or by using the context menu, allows for
toggling of the Cap... |
PowerShellCorpus/PoshCode/Get-UIInput.ps1 | Get-UIInput.ps1 | function Get-UIInput {
#.Synopsis
# Prompt the user for input with a pretty dialog
#.Parameter PromptText
# The text to prompt the user for (an array of one or more strings)
#.Example
# Get-UIInput "First Name:", "Last Name:", "Age:"
Param([string[]]$PromptText = "Ple... |
PowerShellCorpus/PoshCode/Get-Parameter_4.ps1 | Get-Parameter_4.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") { continue }
}
$process = "" | Select-Object ... |
PowerShellCorpus/PoshCode/VMware Lab Manager _1.x.ps1 | VMware Lab Manager _1.x.ps1 | function Ignore-SslErrors {
# Create a compilation environment
$Provider=New-Object Microsoft.CSharp.CSharpCodeProvider
$Compiler=$Provider.CreateCompiler()
$Params=New-Object System.CodeDom.Compiler.CompilerParameters
$Params.GenerateExecutable=$False
$Params.GenerateInMemory=$True
$Params.IncludeDebugIn... |
PowerShellCorpus/PoshCode/Colorize Subversion SVN_1.ps1 | Colorize Subversion SVN_1.ps1 | ## SVN STAT colorizer - http://www.overset.com/2008/11/18/colorized-subversion-svn-stat-powershell-function/
function ss () {
$c = @{ "A"="Magenta"; "D"="Red"; "C"="Yellow"; "G"="Blue"; "M"="Cyan"; "U"="Green"; "?"="DarkGray"; "!"="DarkRed" }
foreach ( $svno in svn stat ) {
@@ $color = $c[$svno.SubString(0,1).... |
PowerShellCorpus/PoshCode/_4.168.1.1.ps1 | _4.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/chkhash_18.ps1 | chkhash_18.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-User.ps1 | Get-User.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/Test if file is writable_1.ps1 | Test if file is writable_1.ps1 | function Test-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
Test-IsWritable -path $foo
Test if file $foo is accesible for write a... |
PowerShellCorpus/PoshCode/Convert Raw SID to SID.ps1 | Convert Raw SID to SID.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/Measure-CommandPerforman.ps1 | Measure-CommandPerforman.ps1 | ##############################################################################\n##\n## Measure-CommandPerformance\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/Test-Prompt_2.ps1 | Test-Prompt_2.ps1 | $choices = [System.Management.Automation.Host.ChoiceDescription[]](
(New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Choose me!"),
(New-Object System.Management.Automation.Host.ChoiceDescription "&No","Pick me!"))
$Answer = $host.ui.PromptForChoice('Caption',"Message",$choices,(1))
Write-... |
PowerShellCorpus/PoshCode/45599912-3e19-46a3-830b-4a7948b8f56d.ps1 | 45599912-3e19-46a3-830b-4a7948b8f56d.ps1 | Function Test-XVM
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory=$true,Position=1)]
[string[]]$Name,
[Parameter(Mandatory=$true,Position=2)]
[string[]]$ComputerName
)
Process
{
$results = @()
foreach ($cName in $ComputerName) {
... |
PowerShellCorpus/PoshCode/Find-DuplicateSMTP.ps1 | Find-DuplicateSMTP.ps1 | #######################################################################
#### Written By: Kevin Dunn ####
#### Date: 1/21/2009 ####
#### ####
#### FindDu... |
PowerShellCorpus/PoshCode/Set-AssemblyBindLogging.ps1 | Set-AssemblyBindLogging.ps1 | function Set-AssemblyBindLogging {
#.Synopsis
# Enable or disable Assembly Bind logging for the machine
#.Parameter EnableLogging
# Whether or not to enable logging. Accepts partial matching of Enable/Disable or True/False or even 1/0 ...
#.Parameter LogPath
# The location of the folder you want to save fusio... |
PowerShellCorpus/PoshCode/Get-Process -eq PSList.ps1 | Get-Process -eq PSList.ps1 | ps | % -b {$arr = @()} -p {
$str = "" | select Name, PID, Time
$str.Name = $_.ProcessName
$str.PID = $_.Id
$str.Time = $(try {$_.StartTime} catch {return [DateTime]::MinValue})
$arr += $str
} -end {$arr | sort Time | ft -a}
|
PowerShellCorpus/PoshCode/RESTful Server.ps1 | RESTful Server.ps1 | # PowerShell RESTful server by Parul Jain paruljain@hotmail.com
# Version 0.1 April 4th, 2013
#
# Use to offer services to other programs as a simple alternative to remoting and webservice technologies
# Does not require a webserver such as IIS. Works on its own!
# Single threaded; will process requests in order.... |
PowerShellCorpus/PoshCode/ELIM (Event Log IM) 1.0.ps1 | ELIM (Event Log IM) 1.0.ps1 | $ELIMServer = $Env:ComputerName
$ELIMChannel = "ELIM"
$ELIMUser = $Env:UserName
function New-ELIMUser {
#.Synopsis
# Send a message to the ELIM (Event Log Instant Messaging) Log
[CmdletBinding()]
param (
# The Computer whose event logs will be used for instant messaging
[String]$Server = $ELIMServer,... |
PowerShellCorpus/PoshCode/Added_Deleted AD Objects.ps1 | Added_Deleted AD Objects.ps1 | #REQUIRES -pssnapin quest.activeroles.admanagement
#REQUIRES -pssnapin Pscx
begin {
# Build variables
$strSMTPServer = "192.168.251.144";
$strEmailFrom = "AD_Admin@hfinc.com";
$strEmailTo = "jdelatorre@hfinc.com";
$borders = "=" * 25;
[int]$days = -60
function TombStonedObjects {
# create Directory Sea... |
PowerShellCorpus/PoshCode/Invoke-SqlCmd_3.ps1 | Invoke-SqlCmd_3.ps1 | #######################
<#
.SYNOPSIS
Runs a T-SQL script.
.DESCRIPTION
Runs a T-SQL script. Invoke-Sqlcmd2 only returns message output, such as the output of PRINT statements when -verbose parameter is specified
.INPUTS
None
You cannot pipe objects to Invoke-Sqlcmd2
.OUTPUTS
System.Data.DataTable
.EXA... |
PowerShellCorpus/PoshCode/WSUS-Settings.ps1 | WSUS-Settings.ps1 | #==================================================================================================
# File Name : WSUS-Settings.ps1
# Original Author : Kenneth C. Mazie (kcmjr at kcmjr.com)
# Description : As written will manually apply all settings associated with a local
# ... |
PowerShellCorpus/PoshCode/Vim25-less Crazy Magic_1.ps1 | Vim25-less Crazy Magic_1.ps1 | cls
$ws = New-WebServiceProxy -Uri "http://192.168.1.1/sdk/vimService?wsdl" -Namespace "vimService1" ;
$ws.Url = "http://192.168.1.1/sdk/vimService";
$ws.UserAgent = "VMware VI Client/4.0.0";
$ws.CookieContainer = New-Object system.net.CookieContainer;
$mor_ret = new-object vimService1.ManagedObjectReferen... |
PowerShellCorpus/PoshCode/Log ports used by applic.ps1 | Log ports used by applic.ps1 | #######################################################################################################################
# File: LogPortsUsedByApplication.ps1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/Get Network Utilization.ps1 | Get Network Utilization.ps1 | $cnt = 'Bytes Total/sec'
$inst = 'Broadcom NetXtreme Gigabit Ethernet - Packet Scheduler Miniport'
$cat = 'Network Interface'
$cnt2 = 'Current Bandwidth'
$cur = New-Object system.Diagnostics.PerformanceCounter($cat,$cnt,$inst)
$max = New-Object system.Diagnostics.PerformanceCounter($cat,$cnt2,$inst)
$curnum = $cu... |
PowerShellCorpus/PoshCode/New-XVM_3.ps1 | New-XVM_3.ps1 | #Examples
<#
New-XVM -Name "WS2012-TestServer01" -SwitchName "Switch(192.168.2.0/24)" -VhdType NoVHD
New-XVM -Name "WS2012-TestServer02" -SwitchName "Switch(192.168.2.0/24)" -VhdType ExistingVHD -VhdPath 'D:\\vhds\\WS2012-TestServer02.vhdx'
New-XVM -Name "WS2012-TestServer03" -SwitchName "Switch(192.168.2.0/24)" ... |
PowerShellCorpus/PoshCode/TabExpansion for V2CTP_2.ps1 | TabExpansion for V2CTP_2.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/Find files not containig.ps1 | Find files not containig.ps1 | # Find all files which does not contains the text in $Pattern
function ssHasNot(
[string] $Path="*.txt"
,[string] $pattern=""
)
{
$has=[string]@(get-childitem $path | ss $pattern | foreach {$_.Path})
get-childitem $path| where {$has.Contains($_.FullName) -eq $false}
}
|
PowerShellCorpus/PoshCode/Simplest animation.ps1 | Simplest animation.ps1 | [int]$x = 0
[int]$y = 0
[int]$cX = 200
[int]$cY = 200
[int]$rad = 100
[int]$grad = 0
[float]$kfc = 0.5
$tabPag1_OnPaint= {
$tmrTim2.Enabled = $false
$g = $tabPag1.CreateGraphics()
$pen = New-Object Drawing.Pen([Drawing.Brushes]::Red)
$g.DrawRectangle($pen, [Convert]::ToInt32($cX - 100), [Convert]... |
PowerShellCorpus/PoshCode/format-iislog.ps1 | format-iislog.ps1 | param
(
[Parameter(
Mandatory=$true,
Position = 0,
ValueFromPipeline=$true,
HelpMessage="Specifies the path to the IIS *.log file to import. You can also pipe a path to Import-Iss-Log."
)]
[ValidateNotNullOrEmpty()]
[string]
$Path,
[Parameter(
Mandatory=$true,
Position = 1,
Value... |
PowerShellCorpus/PoshCode/Get- ExchangeMBStore.ps1 | Get- ExchangeMBStore.ps1 | Param (
[Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
[alias("Name","ComputerName")]$Computer=@("xcserver01")
)
process{
$XCinfo = GetXCDatabases $Computer
$XCMaintInfo = GetMBStoreMaintenance $Computer
foreach ($DB in $XCinfo){
try{
$DB.WhiteSpace = $XCMaintInfo[$D... |
PowerShellCorpus/PoshCode/Get-WMIVersions_2.ps1 | Get-WMIVersions_2.ps1 | #Requires -Version 2
param ( $Credential, $ComputerName )
# The official way to detect .NET versions is to look at their known location on the hard drive as per
# this article: http://msdn.microsoft.com/en-us/kb/kb00318785.aspx
# thanks to David M (http://twitter.com/makovec) for the WQL
$query = "select name... |
PowerShellCorpus/PoshCode/Get-WebFile _1.1.ps1 | Get-WebFile _1.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/PS2WCF_6.ps1 | PS2WCF_6.ps1 | <#
.SYNOPSIS
Functions to call WCF Services With PowerShell.
.NOTES
Version 1.2 11.02.2012
Requires Powershell v2 and .NET 3.5
Original version by Christian Glessner
Blog: http://www.iLoveSharePoint.com
Twitter: http://twitter.com/cglessner
Codeplex: http://codeplex.com/iLoveSharePoint
PowerS... |
PowerShellCorpus/PoshCode/USB Script backup_3.ps1 | USB Script backup_3.ps1 | <#
.SYNOPSIS
Backup-ToUSB.ps1 (Version 2.2, 9 Jan 2012)
.DESCRIPTION
This script will backup recently changed *.ps1,*.psm1,*.psd1 files from any
selected folder (default is $pwd) to any number of inserted USB devices, on
which an archive folder 'PSarchive' will be created if it does not already
exist.
As a U... |
PowerShellCorpus/PoshCode/Get-AclMisconfiguration..ps1 | Get-AclMisconfiguration..ps1 | ##############################################################################\n##\n## Get-AclMisconfiguration\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\n... |
PowerShellCorpus/PoshCode/Out-Balloon.ps1 | Out-Balloon.ps1 | <#
.Synopsis
Makes a baloon tip in the notification area
.Description
With just a few arguments, it is easy to make some text appear in a little balloon.
You can specify an icon file (*.ico) with the -icon argument, if you don't then
the embedded ! icon is used. It's blue.
out-b... |
PowerShellCorpus/PoshCode/New Switch and Portgroup.ps1 | New Switch and Portgroup.ps1 | get-vc vcservername
Get-VMHost | New-VirtualSwitch -Name SwitchName
Get-VMHost | Get-VirtualSwitch -Name SwitchName | New-VirtualPortGroup -Name portgroupname -VLANID vlan_number
|
PowerShellCorpus/PoshCode/Write-DataTable_3.ps1 | Write-DataTable_3.ps1 | #######################
<#
.SYNOPSIS
Creates a DataTable for an object
.DESCRIPTION
Creates a DataTable based on an objects properties.
.INPUTS
Object
Any object can be piped to Out-DataTable
.OUTPUTS
System.Data.DataTable
.EXAMPLE
$dt = Get-Alias | Out-DataTable
This example creates a DataTable fro... |
PowerShellCorpus/PoshCode/Get-DomainPasswordPolicy.ps1 | Get-DomainPasswordPolicy.ps1 | function Get-DomainPasswordPolicy
{
$domain = [ADSI]"WinNT://$env:userdomain"
$Name = @{Name="DomainName";Expression={$_.Name}}
$MinPassLen = @{Name="Minimum Password Length (Chars)";Expression={$_.MinPasswordLength}}
$MinPassAge = @{Name="Minimum Password Age (Days)";Expression={$_.MinPasswordAge.value/86... |
PowerShellCorpus/PoshCode/Custom Accelerators CTP3.ps1 | Custom Accelerators CTP3.ps1 | #requires -version 2.0
## Custom Accelerators for PowerShell 2 (CTP3)
####################################################################################################
## A script module for CTP3 which allows the user to create their own custom type accelerators.
## Thanks to "Oisin Grehan for the discovery":ht... |
PowerShellCorpus/PoshCode/8c4d244d-22ac-4bfe-8ddf-c0a5ee0b552c.ps1 | 8c4d244d-22ac-4bfe-8ddf-c0a5ee0b552c.ps1 | function out-default() {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true)]
[System.Management.Automation.PSObject]
${InputObject})
begin
{
try {
$outBuffer = $null
if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer) -and $outBuffer -gt 1024)
... |
PowerShellCorpus/PoshCode/Invoke-RemoteExpression..ps1 | Invoke-RemoteExpression..ps1 | ##############################################################################\n##\n## Invoke-RemoteExpression\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\n... |
PowerShellCorpus/PoshCode/Custom Speech Commands.ps1 | Custom Speech Commands.ps1 | @@#Filename commands.ps1
import-module "G:\\Documents\\Speech Macros\\custom.psm1"
import-module "G:\\Documents\\Speech Macros\\alice.psm1"
Add-SpeechCommands @{
"test command" = { Say $(Respond "3:2,4:0-2") }
" * the percentages * " = { Say $(Percentages) }
" * star date * " = { Say "Curren... |
PowerShellCorpus/PoshCode/Send-HTMLFormattedEmail_3.ps1 | Send-HTMLFormattedEmail_3.ps1 | #-------------------------------------------------
# Send-HTMLFormattedEmail
#-------------------------------------------------
# Usage: Used to send an HTML Formatted Email that is based on an XSLT template.
#-------------------------------------------------
function Send-HTMLFormattedEmail{
param ( [string]... |
PowerShellCorpus/PoshCode/forever.ps1 | forever.ps1 | forever
|
PowerShellCorpus/PoshCode/powertab patch.ps1 | powertab patch.ps1 | # When in the cert provider - objects returned by gci must be completed by a particular member (not by ToString).
# This can be done more generically but for now this is super handy to complete with these types
$firstChildType = $childitems[0].GetType()
if ($firstChildType -is [Microsoft.Power... |
PowerShellCorpus/PoshCode/Citrix License Info.ps1 | Citrix License Info.ps1 | ###########################################
# Licence Checking Script for Citrix #
# Virtu-Al - http://teckinfo.blogspot.com/
###########################################
param( [string] $sendmailsched )
Function Sendemail ($LicTypeText, $InstalledLicNum, $InUseNum, $PercentageNum)
{
#Email options for automa... |
PowerShellCorpus/PoshCode/New-SQLComputerLogin_1.ps1 | New-SQLComputerLogin_1.ps1 | # Depends on Invoke-SQLCmd2 http://poshcode.org/2950
# Depends on Get-ADComputer http://poshcode.org/3009
function New-SqlComputerLogin {
#.Synopsis
# Creates a Login on the specified SQL server for a computer account
#.Example
# New-SqlComputerLogin -SQL DevDB2 -Computer BuildBox2 -Force
#
# Specifying the F... |
PowerShellCorpus/PoshCode/SetDefaultPrinter_1.ps1 | SetDefaultPrinter_1.ps1 | <#
.SYNOPSIS
Sets the Default Printer for any user on any machine in active directory.
.DESCRIPTION
Search AD for Computername; Select User Account and Printer and make that printer the default
printer for that user on that computer.
.PARAMETER Hostnme
This parameter is required and should reflect the ... |
PowerShellCorpus/PoshCode/8b815eb7-c620-4159-b0fc-435ceeca036b.ps1 | 8b815eb7-c620-4159-b0fc-435ceeca036b.ps1 | # Add the Active Directory bits and not complain if they're already there
Import-Module ActiveDirectory -ErrorAction SilentlyContinue
# set default password
# change pass@word1 to whatever you want the account passwords to be
$defpassword = (ConvertTo-SecureString "pass@word1" -AsPlainText -force)
# Get domain... |
PowerShellCorpus/PoshCode/New-UrlFile.ps1 | New-UrlFile.ps1 | function New-UrlFile
{
param( $URL = "http://www.google.com")
$UrlFile = [system.io.Path]::ChangeExtension([system.io.Path]::GetTempFileName(),".url")
$UrlFileContents = `
"[InternetShortcut]",
"URL=$URL"
Write-Host $URL
$UrlFileContents | Set-Content -Path $UrlFile
Get-Item $UrlFile
}
|
PowerShellCorpus/PoshCode/Get-PrivateKeyPath.ps1 | Get-PrivateKeyPath.ps1 | #requires -Version 2.0
function Get-PrivateKeyPath
{
param
(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)]
[System.Security.Cryptography.X509Certificates.X509Certificate2]
[ValidateScript( { ( $_ -is [System.Security.Cryptography.X509Certificates.X509Certificate2] ) } ) ]
$Ce... |
PowerShellCorpus/PoshCode/Invoke-PoshCode.ps1 | Invoke-PoshCode.ps1 | # .Summary
# Download and execute a script block from PoshCode.org
# .Description
# Download the code for a PoshCode script based on search of by specific index.
# Execute the code as a script block, passing arguments to it.
#
# Note: this is scary, and you should only use it if you really know what you're doing ... |
PowerShellCorpus/PoshCode/Get-Credential.ps1 | Get-Credential.ps1 | function Get-Credential{
PARAM([String]$Title, [String]$Message, [String]$Domain, [String]$UserName, [switch]$Console)
## Carefully EA=SilentlyContinue and check for $True because by default it's MISSING (not False, as you might expect)
$cp = (Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellI... |
PowerShellCorpus/PoshCode/Get-MacAddressOui_1.ps1 | Get-MacAddressOui_1.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/Add-UniqueEndings.ps1 | Add-UniqueEndings.ps1 | ## Add-UniqueEndings
## Takes an array of strings and forces them to be unique by adding _<number> tails to duplicates.
####################################################################################################
## Usage:
## $$: (Add-UniqueEndings "one","two","three","one","two","one","one_5").ToString()... |
PowerShellCorpus/PoshCode/$env_PATH permanently.ps1 | $env_PATH permanently.ps1 | #requires -version 2
param(
[string] $AddedFolder,
[bool] $ApplyImmediately = $true
)
$environmentRegistryKey = 'Registry::HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment'
$oldPath = (Get-ItemProperty -Path $environmentRegistryKey -Name PATH).Path
# See if a n... |
PowerShellCorpus/PoshCode/a4d96102-d5a8-4437-b3e0-568a0936fcbf.ps1 | a4d96102-d5a8-4437-b3e0-568a0936fcbf.ps1 | # The $test variable can be pretty much whatever you want it to be, or with a little adjustment it isn't even necessary.
# I just wanted to set it up like this for the $match variable later on
$test=(get-folder testing|get-vm)
#$data and the csv is where all the information lies that this script/s pulls
$data=imp... |
PowerShellCorpus/PoshCode/Get-SerialNumber.ps1 | Get-SerialNumber.ps1 | function Get-SerialNumber {
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.OtherId... |
PowerShellCorpus/PoshCode/Start-RDP_2.ps1 | Start-RDP_2.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/ESXiMgmt module.ps1 | ESXiMgmt module.ps1 | #######################################################################################################################
# File: ESXiMgmt.psm1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/finddupe_3.ps1 | finddupe_3.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/Custom Speech Commands_1.ps1 | Custom Speech Commands_1.ps1 | #Filename commands.ps1
import-module "G:\\Documents\\Speech Macros\\custom.psm1"
import-module "G:\\Documents\\Speech Macros\\alice.psm1"
Add-SpeechCommands @{
"test command" = { Say $(Respond "3:2,4:0-2") }
" * the percentages * " = { Say $(Percentages) }
" * star date * " = { Say "Current,... |
PowerShellCorpus/PoshCode/Set Single email .ps1 | Set Single email .ps1 | # Very simple script to use in Exchange 2007 with a dead simple task
# Create an email enabled user with the local Email Address Policy Disabled with a SINGLE email address
# Attached to it
#
# This can be used in an environment where you may have multiple email addresses but don't want an account picking
# up mul... |
PowerShellCorpus/PoshCode/ProcuriosJSON.psm1.ps1 | ProcuriosJSON.psm1.ps1 | function ConvertFrom-Json {
param (
[Parameter( Mandatory = $true, ValueFromPipeline = $true, Position = 0)]
[Alias("Json")]
[string[]]
$InputObject,
[switch]$AsPSObject = $false
)
Process {
$output = [procurios.Public.JSON]::JsonDecode( $InputObject )
if ( $AsPSObject ) {
$output | ForEa... |
PowerShellCorpus/PoshCode/Deny-PendingRequest.ps1 | Deny-PendingRequest.ps1 | #####################################################################
# Deny certificate request.ps1
# Version 1.0
#
# Denies 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/Explorer Style Script.ps1 | Explorer Style Script.ps1 | $nul = "<NULL>"
$type = "Directory", "File"
function Show-Error([string]$mes) {
[Windows.Forms.MessageBox]::Show($mes, "Error",
[Windows.Forms.MessageBoxButtons]::OK,
[Windows.Forms.MessageBoxIcon]::Exclamation
)
}
function Add-RootsTree {
[IO.Directory]::GetLogicalDrives() | % {
$nod = ... |
PowerShellCorpus/PoshCode/Get-HexDump.ps1 | Get-HexDump.ps1 | <#
Required v2.0
Using examples:
PS C:\\> gi .\\foo | hex -b 150
Dumps first 150 bytes of foo.
PS C:\\> hex .\\foo -b 150
It's equal first command.
#>
function Get-HexDump {
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
... |
PowerShellCorpus/PoshCode/Mailbox User_Update.ps1 | Mailbox User_Update.ps1 | #Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms v1.0.1.0
# Generated On: 5/10/2010 9:28 AM
# Generated By: Bernard Chouinard berchouinard@gmail.com
# This script requires Powershell v2
#... |
PowerShellCorpus/PoshCode/1027025e-d46a-4d37-a5b0-b1c76068dc6b.ps1 | 1027025e-d46a-4d37-a5b0-b1c76068dc6b.ps1 | # Code to auto update the Address policy, GAL, OAB and storage groups and mailbox databases of an Exchange 2007 server by John McLear
# This code is good for hosting providers or people who wish to use lots of storage groups and mailbox databases.
#
# Thanks to Joel Bennett (Jaykul) for general scripting help and t... |
PowerShellCorpus/PoshCode/ISE-Lines.ps1 | ISE-Lines.ps1 | #requires -version 2.0
## ISE-Lines module v 1.0
## DEVELOPED FOR CTP3
## See comments for each function for changes ...
##############################################################################################################
## Provides Line cmdlets for working with ISE
## Duplicate-Line - Duplicates curr... |
PowerShellCorpus/PoshCode/createSiteFromTemplate.ps1 | createSiteFromTemplate.ps1 | # Load the template
$url = "http://spf" # where template base
$namesite = "Good Site" #name new site title
$targeturl = "goodsite" #name url new site
# find id = viewAlltemplate
$templateID = "{055CF2A7-43A8-48E1-95CB-19DC393F0215}"
#$templateID = "{055CF2A7-43A8-48E1-95CB-19DC393F0215}#kolam"
$site= new-Objec... |
PowerShellCorpus/PoshCode/RunSSIS.ps1 | RunSSIS.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller
### </Author>
### <Description>
### Executes a SQL Server Integrations Services package for both server and file system storage types.
### Optionally Resets a Package Configuration connection ... |
PowerShellCorpus/PoshCode/Test Ora Proc Wrapper 1.ps1 | Test Ora Proc Wrapper 1.ps1 | # this is a testcase for http://code.google.com/p/poshcodegen/
# a project for generating PowerShell function wrappers around stored procedure call, and more.
# Here we show how to return a resultsets (aka ref cursors) from an Orcale stored procedures using ADO.NET with PowerShell
# by the way it tell the verion... |
PowerShellCorpus/PoshCode/Start-Demo 3.3.ps1 | Start-Demo 3.3.ps1 | ## Start-Demo.ps1
##################################################################################################
@@## This is an overhaul of Jeffrey Snover's original Start-Demo script by Joel "Jaykul" Bennett
##
## I've switched it to using ReadKey instead of ReadLine (you don't have to hit Enter each time)
#... |
PowerShellCorpus/PoshCode/Get-NewPassword.ps1 | Get-NewPassword.ps1 | #/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\
#
# Script Name: Get-NewPassword.ps1
# Title: Random Password Generator
# Version: 1.0
# Author: johnwcannon at gmail dot com
# Date: September 16th, 2010
#
# Description: Password gerneration function based... |
PowerShellCorpus/PoshCode/814ade13-24cf-4b85-beea-d9492ddd8e1e.ps1 | 814ade13-24cf-4b85-beea-d9492ddd8e1e.ps1 | $DriveLetter = "D:"
$MaxShrink = 0.30 # 0.30 equals 30%
$MinShrink = 0.20 # 0.20 equals 20%
$FileLocation = $env:Temp
$FileName4DiskPart = "Shrink.txt"
$DiskDrive = GWMI -CL Win32_LogicalDisk | Where {$_.DeviceId -Eq "$DriveLetter"}
$DriveSize = ($DiskDrive.Size /1GB)
$DriveSize = [int]$DriveSize
$DesiredSh... |
PowerShellCorpus/PoshCode/Set Logfile length.ps1 | Set Logfile length.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/Async SQL Backup .ps1 | Async SQL Backup .ps1 | $backuppath = "\\\\server\\sqlbackups\\"
$alertaddress = "jrich523@domain.com"
$smtp = "smtp.domain.com"
$retaindays = 14
$hname = (gwmi win32_computersystem).name
$errorstate = 0
$body =@()
$backups = @()
$conns = @()
$completed = @{}
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.S... |
PowerShellCorpus/PoshCode/New-CodeSigningCert.ps1 | New-CodeSigningCert.ps1 | ## New-CodeSigningCert.ps1
########################################################################################################################
## Does the setup needed to self-sign PowerShell scripts ...
## Generates a "test" self-signed root Certificate Authority
## And then generates a code-signing certific... |
PowerShellCorpus/PoshCode/Get-Scope_3.ps1 | Get-Scope_3.ps1 | function Get-Scope {
#.Synopsis
# Determine the scope of execution (are you in a module? how many scope layers deep are you?)
#.Parameter Invocation
# In order to correctly determine the scope, this function requires that you pass in the $MyInvocation variable when you call it.
#.Parameter ToHost
# If you jus... |
PowerShellCorpus/PoshCode/FindNewVirtualMachines_1.ps1 | FindNewVirtualMachines_1.ps1 | #requires -pssnapin VMware.Vimautomation.Core
Param(
[int]
$LastDays
)
Process
{
$EventFilterSpecByTime = New-Object VMware.Vim.EventFilterSpecByTime
If ($LastDays)
{
$EventFilterSpecByTime.BeginTime = (get-date).AddDays(-$($LastDays))
}
$EventFilterSpec = New-Object VMwa... |
PowerShellCorpus/PoshCode/vProfiles.ps1 | vProfiles.ps1 | #
# vProfiles V1
# By Alan Renouf
# http://virtu-al.net
#
#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.3.0
# Generated On: 27/06/2009 9:17 PM
# Generated... |
PowerShellCorpus/PoshCode/Autoload (beta).ps1 | Autoload (beta).ps1 | #Requires -Version 2.0
## Automatically load functions from scripts on-demand, instead of having to dot-source them ahead of time, or reparse them from the script every time.
## To use:
## 1) Create a function. To be 100% compatible, it should specify pipeline arguments
## For example:
<#
function Skip-Object {... |
PowerShellCorpus/PoshCode/Script-Proc_2.sql.ps1 | Script-Proc_2.sql.ps1 | #Copyright (c) 2011 Justin Dearing
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, dist... |
PowerShellCorpus/PoshCode/PoshCode ISE Addon_2.ps1 | PoshCode ISE Addon_2.ps1 | if (!(Get-Module WPK)) {Import-Module -global WPK}
if (!(Get-Module PoshCode)) {Import-Module -global PoshCode}
Function Get-PoshCodePreferences {
if (Get-Item $global:xmlPath -ErrorAction SilentlyContinue) {
try {
$pcPreferences = Import-Clixml -Path $global:xmlPath
$global:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.