full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Pause.ps1 | Pause.ps1 | ## Pause (aka Pause-Script)
## Pause the script and wait for user action
###################################################################################################
## Parameters (are all OPTIONAL)
## Message - the message to use as the prompt to the user
## ReturnKey - when present, the scri... |
PowerShellCorpus/PoshCode/ConvertTo-MultiArray_1.ps1 | ConvertTo-MultiArray_1.ps1 | function ConvertTo-MultiArray {
<#
.Notes
NAME: ConvertTo-MultiArray
AUTHOR: Tome Tanasovski
Website: http://powertoe.wordpress.com
Twitter: http://twitter.com/toenuff
Version: 1.1
CREATED: 11/5/2010
LASTEDIT:
11/5/2010 1.0
Initial Release
11/5/2010 1.1
Removed array parameter and passes a ... |
PowerShellCorpus/PoshCode/Save-Credentials_3.ps1 | Save-Credentials_3.ps1 | <#
.SYNOPSIS
The script saves a username and password, encrypted with a custom key to to a file.
.DESCRIPTION
The script saves a username and password, encrypted with a custom key to to a file. The key is coded into the script but should be changed before use. The key allows the password to be decrypted ... |
PowerShellCorpus/PoshCode/PowerBoots Gadgets.ps1 | PowerBoots Gadgets.ps1 | $gadgetWindow = @{
# Transparency, WindowStyle, and background work together
# to get rid of the standard window's chrome and make the window "irregular" shaped
# that is, the window will be the shape of it's content.
AllowsTransparency = $True
WindowStyle = "None"
Background = "Transparent"
... |
PowerShellCorpus/PoshCode/Get-PageUrls.ps1 | Get-PageUrls.ps1 | ##############################################################################\n##\n## Get-PageUrls\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nParse all of th... |
PowerShellCorpus/PoshCode/out-form with sort colum_2.ps1 | out-form with sort colum_2.ps1 | # I think OUT-FORM is a very usefull function. I've added code to sort columns by clicking on headers.
# You nedd just add the columnTag parameters specifing if colunm value is text or numeric:
# out-form -data (get-process) -columnNames ("Name", "ID" ) -columnProperties ("Name", "ID") -columnTag ("Text", "Numeri... |
PowerShellCorpus/PoshCode/New-CustomColumn (V1.0).ps1 | New-CustomColumn (V1.0).ps1 | # Function New-CustomColumn for PowerShell V1.0
#
# Helper function to create Custom Columns for select or format cmdlets
# for more info and examples see :
# http://thepowershellguy.com/blogs/posh/archive/2009/01/26/new-customcolumn-function-powershell-v1-0.aspx
#
# /\\/\\o\\/\\/ 2008
# http://thePowerShellGuy.... |
PowerShellCorpus/PoshCode/Start-Elevated.ps1 | Start-Elevated.ps1 | #function Start-Elevated {
param ($app)
$psi = new-object "System.Diagnostics.ProcessStartInfo"
$psi.FileName = $app;
$psi.Arguments = [string]$args;
$psi.Verb = "runas";
[System.Diagnostics.Process]::Start($psi)
#}
|
PowerShellCorpus/PoshCode/Snippet Compiler_3.ps1 | Snippet Compiler_3.ps1 | $def = $(if ((gi .).FullName -eq (gi .).Root) {
([string](gi .).Root).TrimEnd("\\")
}
else { (gi .).FullName }
)
##################################################################################################
function Get-CursorPoint {
$x = $rtbEdit.SelectionStart - $... |
PowerShellCorpus/PoshCode/new-pshash.ps1 | new-pshash.ps1 | #this function takes nested hashtables and converts them to nested pscustomobjects
#it can also contain arrays of hashtables, and it will turn those hashtables in the arrays
#also into PScustomobjects
function new-pshash
{
[CmdletBinding()]
PARAM(
[parameter(valuefromPipeline=$true,Mandatory=$true, position = 1... |
PowerShellCorpus/PoshCode/AD FSMO Roles.ps1 | AD FSMO Roles.ps1 | function Get-FSMORole {
<#
.SYNOPSIS
Retrieves the FSMO role holders from one or more Active Directory domains and forests.
.DESCRIPTION
Get-FSMORole uses the Get-ADDomain and Get-ADForest Active Directory cmdlets to determine
which domain controller currently holds each of the Active Directory FSMO roles.
.PARA... |
PowerShellCorpus/PoshCode/ff51eafa-111d-4023-b84d-e6e62b361e34.ps1 | ff51eafa-111d-4023-b84d-e6e62b361e34.ps1 | @@ Get-VIServer YOURSERVER
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Addsheet = $Excel.sheets.Add()
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(1,1) = "Name"
$Sheet.Cells.Item(1,2) = "Power State"
$Sheet.Cells.Item(1,3) = "Description"
$Sheet.... |
PowerShellCorpus/PoshCode/Install-Module.ps1 | Install-Module.ps1 | function Install-Module {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Mandatory=$true)]
[Alias("PSPath")]
[String]$ModuleFilePath
, [Switch]$Global
)
## Get the Full Path of the module file
$ModuleFilePath = Resolve-Path $ModuleFilePat... |
PowerShellCorpus/PoshCode/VCenter Reporting.ps1 | VCenter Reporting.ps1 | <# .SYNOPSIS
Collects statistics and settings for Hosts, Datastores, and Virtual Machines
from multiple VCenters.
.DESCRIPTION
Creates Excel spreadsheet report with separate worksheets for Hosts, Datastores, and
Virtual Machines by VCenter.
.PARAMETER
none
.INPUTS
.OU... |
PowerShellCorpus/PoshCode/Get-VMCreationReport.ps1 | Get-VMCreationReport.ps1 | # Report VMs created per month.
# Before you begin run Alan's "Who Created that VM?" script.
# http://www.virtu-al.net/2010/02/23/who-created-that-vm/
function Get-VMCreationReport {
Get-VM | Group {
if ($_.CustomFields["CreatedOn"] -as [DateTime] -ne $null) {
"{0:Y}" -f [DateTime]$_.CustomFields["CreatedOn... |
PowerShellCorpus/PoshCode/Get-Constructor_2.ps1 | Get-Constructor_2.ps1 | function Get-Constructor {
PARAM( [Type]$type )
$type.GetConstructors() |
Format-Table @{
l="$($type.Name) Constructors"
e={ "New-Object $($type.FullName) $(($_.GetParameters() | ForEach { "[{0}] `${1}" -f $($_.ToString() -split " ") }) -Join ", ")" }
}
}
Set-Alias gctor Get-Constructor
|
PowerShellCorpus/PoshCode/VMtoolsUpgrade_1.ps1 | VMtoolsUpgrade_1.ps1 | #####################################################################
# TIAA-CREF VMWare Standard Scripts - PowerCLI
#
# Purpose: "Check and upgrade Tools during power cycling"
# Author: David Chung
# Support: IT Infrastructure
# Docs: N/A
#
# Instruction: 1. Create CSV file with list of servers
# ... |
PowerShellCorpus/PoshCode/43a28a15-5023-4feb-a71f-abe95aa0f2a6.ps1 | 43a28a15-5023-4feb-a71f-abe95aa0f2a6.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(
Position = 1,
HelpMessage="Specifies the d... |
PowerShellCorpus/PoshCode/Hack ESX MOTD.ps1 | Hack ESX MOTD.ps1 | $screen = @"
You see here a virtual switch. ------------ ------
#...........| |....|
--------------- ###------------ |...(|
|..%...........|########## ###-@...|
... |
PowerShellCorpus/PoshCode/Invoke-Member.ps1 | Invoke-Member.ps1 | ##############################################################################\n##\n## Invoke-Member\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\nEnables ea... |
PowerShellCorpus/PoshCode/Print Cluster Comparison.ps1 | Print Cluster Comparison.ps1 | <#################################################################
# Print Cluster - Printer Comparison #
# #
# This script does a comparison between two print clusters and #
# looks for differences between the source and dest... |
PowerShellCorpus/PoshCode/Force 64 bit for script.ps1 | Force 64 bit for script.ps1 | # am I running in 32 bit shell?
if ($pshome -like "*syswow64*") {
write-warning "Restarting script under 64 bit powershell"
# relaunch this script under 64 bit shell
# if you want powershell 2.0, add -version 2 *before* -file parameter
& (join-path ($pshome -replace "syswow64", "sysnative") powershell.exe... |
PowerShellCorpus/PoshCode/Get-ChildItemRecurse_1.ps1 | Get-ChildItemRecurse_1.ps1 | function Get-ChildItemRecurse {
<#
.Synopsis
Does a recursive search through a PSDrive up to n levels.
.Description
Does a recursive directory search, allowing the user to specify the number of
levels to search.
.Parameter path
The starting path.
.Parameter fileglob
(optional) the search string for ... |
PowerShellCorpus/PoshCode/IniFile Functions _1.0.ps1 | IniFile Functions _1.0.ps1 | function Get-IniSection($inifile,$section)
{
$sections = select-string "^\\[.*\\]" $inifile
if(!$section) {
return $sections | %{$_.Line.Trim("[]")}
}
$start = 0
switch($sections){
{$_.Line.Trim() -eq "[$section]"}{
$start = $_.LineNumber -1
}
defaul... |
PowerShellCorpus/PoshCode/Invoke-BinaryProcess.ps1 | Invoke-BinaryProcess.ps1 | ##############################################################################\n##\n## Invoke-BinaryProcess\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\nInv... |
PowerShellCorpus/PoshCode/Fast vMotion with GUI.ps1 | Fast vMotion with GUI.ps1 | #Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.3.0
# Generated On: 7/21/2009 2:07 PM
# Generated By: afokkema
###################################################... |
PowerShellCorpus/PoshCode/5c778a26-8386-434c-8824-00c38db7c470.ps1 | 5c778a26-8386-434c-8824-00c38db7c470.ps1 | param([Parameter(Mandatory=$true)][string]$Path,[Parameter(Mandatory=$true)][string]$Destination)
Get-ChildItem -Path $Path | Where-Object { !$_.PSIsContainer } | foreach {
$Target = Join-Path -Path $Destination -ChildPath (Split-Path -Leaf $_)
if ( Test-Path -Path $Target -PathType Leaf ) {
$PrevTargetBkup=(... |
PowerShellCorpus/PoshCode/Test-EmptyFolder.ps1 | Test-EmptyFolder.ps1 | function Test-EmptyFolder {
<#
.SYNOPSIS
Tests for empty folders.
.DESCRIPTION
The Test-EmptyFolder function tests if a specified folder is empty by checking if it
contains files or folders. The function returns the folder path and a boolean value for empty.
.PARAMETER Path
Specifies the path of ... |
PowerShellCorpus/PoshCode/Backup-EventLogs.ps1 | Backup-EventLogs.ps1 | Function Backup-EventLogs
{
<#
.SYNOPSIS
Backup Eventlogs from remote computer
.DESCRIPTION
This function backs up all logs on a Windows computer that have events written in them. This
log is stored as a .csv file in the current directory, where the filenam... |
PowerShellCorpus/PoshCode/ConvertTo-Hex_10.ps1 | ConvertTo-Hex_10.ps1 | # Ported from C# technique found here: http://forums.asp.net/p/1298956/2529558.aspx
param ( [string]$SidString )
# Create SID .NET object using SID string provided
$sid = New-Object system.Security.Principal.SecurityIdentifier $sidstring
# Create a byte array of the proper length
$sidBytes = New-Object byte[] ... |
PowerShellCorpus/PoshCode/Get-PerformanceCounter.ps1 | Get-PerformanceCounter.ps1 | function Get-PerformanceCounter {
<#
.Synopsis
Gets one or more Performance Counter objects.
.Description
This function will use .NET to retrieve a single Counter or all counters
for a particular Instance and Category.
.Parameter category
The Performance Counter Category.
... |
PowerShellCorpus/PoshCode/Get-ProxyAddress_1.ps1 | Get-ProxyAddress_1.ps1 | Param (
[Parameter(Mandatory=$true,
Position=0,
ValueFromPipeline=$true,
HelpMessage="Enter SMTP address to search for in Active-Directory."
)]
[string]$objSMTP
)
Function Get-ProxyAddresses ([string]$Address){
$objAD = $null
$objAD = Get-QADObject -LdapFilter "(proxyAddre... |
PowerShellCorpus/PoshCode/Set-Prompt_1.ps1 | Set-Prompt_1.ps1 | param([Alias("copy","demo")][Switch]$Pasteable)
# This should go OUTSIDE the prompt function, it doesn't need re-evaluation
# We're going to calculate a prefix for the window title
# Our basic title is "PoSh - C:\\Your\\Path\\Here" showing the current path
if(!$global:WindowTitlePrefix) {
# But if you're runni... |
PowerShellCorpus/PoshCode/ASPX Mailbox (2 of 6).ps1 | ASPX Mailbox (2 of 6).ps1 | public partial class MailboxTasks : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
System.Text.StringBuilder sbValid = new System.Text.StringBuilder();
sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sbValid.Append("if (Page_Cl... |
PowerShellCorpus/PoshCode/ProgressMessage .ps1 | ProgressMessage .ps1 | #Generated Form Function
function ProgressMessage {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
# Generated On: 29/01/2013 11:01 AM
# Generated By: admstpierdj
#####################################... |
PowerShellCorpus/PoshCode/Computer Inventory_2.ps1 | Computer Inventory_2.ps1 | # ========================================================
#
# Script Information
#
# Title: Remote Computer Inventory
# Author: Assaf Miron
# Originally created: 21/06/2008
# Original path: Computer-Inventory.PS1
# Description: Collects Remote Computer Data Using WMI and Registry Access
# Outputs... |
PowerShellCorpus/PoshCode/Quickstats from VMware.ps1 | Quickstats from VMware.ps1 | connect-VIServer yourserver
# Written by Alan Renouf - Check http://teckinfo.blogspot.com for more examples
# This can easily be changed to pass parameters or be used as a function
# Set the following 3 variables for your needs
# Example stats are:
# % CPU Usage - cpu.usage.average
# Mhz CPU Usage - cpu.usageMH... |
PowerShellCorpus/PoshCode/PS2WCF.ps1 | PS2WCF.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/Resize-Image.ps1 | Resize-Image.ps1 | ## NOTE: Destination must end in .bmp, .gif, .png, .wmp, .jpeg or .tiff
param($source = "C:\\Windows\\Web\\Wallpaper\\Windows\\img0.jpg", $destination = "$Home\\Pictures\\thumb0.png", $scale = 0.25)
Add-Type -Assembly PresentationCore
## Open and resize the image
$image = New-Object System.Windows.Media.Imaging.T... |
PowerShellCorpus/PoshCode/Map a Network Drive_1.ps1 | Map a Network Drive_1.ps1 | function MapNetDrive
{
param(
#Non-Boolean parameters (Values)
#
[Parameter(Position=0,Mandatory=$true)]
[string]$DriveLetter="Z:",
[Parameter(Position=1,Mandatory=$true)]
[string]$Path,
#Boolean switches (On/Off)
#
[Parameter(Position=2,Mandatory=$false)]... |
PowerShellCorpus/PoshCode/List AD Users CSV_2.ps1 | List AD Users CSV_2.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/NIC Performance.ps1 | NIC Performance.ps1 | $cat = New-Object system.Diagnostics.PerformanceCounterCategory("Network Interface")
$inst = $nic.GetInstanceNames()
foreach ( $nic in $inst ) {
$a = $nic.GetCounters( $nic )
$a | ft CounterName, { $_.NextValue() } -AutoSize
}
|
PowerShellCorpus/PoshCode/Get-DPMRecoveryPointRepo.ps1 | Get-DPMRecoveryPointRepo.ps1 | <#
.SYNOPSIS
Get-DPMRecoveryPointReport
.DESCRIPTION
This script sets up the basic framework that I use for all my scripts.
.PARAMETER DPMServerName
The FQDN of your DPM server
.EXAMPLE
Get-DPMRecoveryPointReport -DPMServerName dpm.company.com
N... |
PowerShellCorpus/PoshCode/Logger.psm1 0.2.ps1 | Logger.psm1 0.2.ps1 | <#
Name : Universal Log4Net Logging Module (Logger.psm1)
Version : 0.2
Author : Joel Bennett (MVP)
Site : http://www.HuddledMasses.org/
Version History:
0.2 - Configless release.
Now configures with inline XML, and supports switches to create "reasonable" default loggers
... |
PowerShellCorpus/PoshCode/foreach-withexception.ps1 | foreach-withexception.ps1 | function foreach-withexception ([scriptblock]$process,$outputexception)
{
begin { $global:foreachex = @() }
process {
try
{
$local:inputitem = $_
&$process
}
catch
{
$local:exceptionitem = 1 | select-object... |
PowerShellCorpus/PoshCode/Convert Raw SID to SID_2.ps1 | Convert Raw SID to SID_2.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/Snippet Compiler.ps1 | Snippet Compiler.ps1 | $def = (gci $MyInvocation.MyCommand.Name).Directory.ToString()
#################################################################################################
$mnuAtom_Click= {
if ($txtEdit.Text -ne "") {
$res = [Windows.Forms.MessageBox]::Show("Do you want to save data before?", `
$fr... |
PowerShellCorpus/PoshCode/Get-LocalGroupMember_4.ps1 | Get-LocalGroupMember_4.ps1 | function Get-LocalGroupMember
{
<#
.Synopsis
Get the local group membership.
.Description
Get the local group membership.
.Parameter ComputerName
Name of the Computer to get group members (Default localhost.)
.Parameter Group
... |
PowerShellCorpus/PoshCode/Query MagisterWebservice.ps1 | Query MagisterWebservice.ps1 | <#
.TITLE
Haal-WisMasLeerling.ps1
.AUTHOR
Paul Wiegmans (p [dot] wiegmans [at] bonhoeffer [dot] nl)
.DATE
2013-01-30
.DESCRIPTION
Send a webquery to Schoolmaster Magister web service and request data
from the list WISMASLEERLING.
Doe een webquery naar Magister webservice en haal de lijst ... |
PowerShellCorpus/PoshCode/Disable AD Users.ps1 | Disable AD Users.ps1 | $NumDays = 90
$LogDir = ".\\Disabled-User-Accounts.log"
$currentDate = [System.DateTime]::Now
$currentDateUtc = $currentDate.ToUniversalTime()
$lltstamplimit = $currentDateUtc.AddDays(- $NumDays)
$lltIntLimit = $lltstampLimit.ToFileTime()
$adobjroot = [adsi]''
$objstalesearcher = New-Object System.DirectorySer... |
PowerShellCorpus/PoshCode/User Entitlement Auditor.ps1 | User Entitlement Auditor.ps1 | $date = ( get-date ).ToString('yyyy-MM-dd-hh-mm')
$inpath = "C:\\InputDir\\"
$outpath = "C:\\Archive\\"
$FileList = @(Get-Childitem $inpath)
# Output CSV formatted report with members properly split up and unwanted domains/users removed:
$ResultFile = [System.IO.Path]::GetTempFileName()
$ADMembersOutfil... |
PowerShellCorpus/PoshCode/Invoke-V2Script.ps1 | Invoke-V2Script.ps1 | # Function may be useful for people who want to play with CTP1 for PowerShell 3 but need to use v2 scripts.
function Invoke-V2Script {
<#
.Synopsis
Will run script currently edited in ISE using powershell V2.
.Description
Will run script currently edited ISE. If it's not saved - it wil... |
PowerShellCorpus/PoshCode/Pivot-Object.ps1 | Pivot-Object.ps1 | #.Synopsis
# Pivot multiple objects which have properties that are name, value pairs
#.Description
# Takes a series of objects where there are multiple rows which have a pair of columns where the values are different on ech row with the name and value of an additional property, and outputs new objects which have t... |
PowerShellCorpus/PoshCode/Poshboard Inactive AD Ac.ps1 | Poshboard Inactive AD Ac.ps1 | @@ # UpdateADPC.ps1, to be run outside of Poshboard
function Get-DomainComputerAccounts
{
# Use Directory Services object to attach to the domain
$searcher = new-object DirectoryServices.DirectorySearcher([ADSI]"")
#Leaving the ADSI statement empty = attach to your root domain
# Filter down to computer accou... |
PowerShellCorpus/PoshCode/Test-WebDAV.ps1 | Test-WebDAV.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/Close by window title_1.ps1 | Close by window title_1.ps1 | using System;
using System.Text;
using System.Drawing;
using System.Reflection;
using System.Diagnostics;
using System.Windows.Forms;
using System.ComponentModel;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("CloseByTitle")]
[assembly: AssemblyVersion("3.5.0.0")]
namespace CloseByTitle {... |
PowerShellCorpus/PoshCode/Invoke-Sql_2.ps1 | Invoke-Sql_2.ps1 | <#
.SYNOPSIS
Runs a T-SQL Query and optional outputs results to a delimited file.
.DESCRIPTION
Invoke-Sql script will run a T-SQL query or stored procedure and optionally outputs a delimited file.
.EXAMPLE
PowerShell.exe -File "C:\\Scripts\\Invoke-Sql.ps1" -ServerInstance "Z003\\sqlprod2" -Database orders -Query ... |
PowerShellCorpus/PoshCode/Create-Printers_2.ps1 | Create-Printers_2.ps1 | ###########################################################################"
#
# NAME: Create-Printers.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
# BLOG: http://blog.powershell.no
#
# COMMENT: Simple script to bulk-create printers on a print-server. Printers are imported from a csv-file.... |
PowerShellCorpus/PoshCode/lol.ps1 | lol.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/partial application.ps1 | partial application.ps1 | Set-StrictMode -Version 2
$commonParameters = @("Verbose",
"Debug",
"ErrorAction",
"WarningAction",
"ErrorVariable",
"WarningVariable",
"OutVariable",
"OutB... |
PowerShellCorpus/PoshCode/Xml Module 4.8.ps1 | Xml Module 4.8.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 Active Sync devices _1.ps1 | Get Active Sync devices _1.ps1 | <#
.SYNOPSIS
Get-InactiveActiveSyncDevices pulls all user mailboxes with an Active Sync partnership and then selects the Active Sync devices that haven't synced in the specified period. These devices are sorted in ascending order and placed in a HTML table which is emailed to the specified user using a specified repl... |
PowerShellCorpus/PoshCode/ADFS local update.ps1 | ADFS local update.ps1 | Add-PSSnapin Microsoft.Adfs.Powershell
Import-Module MSOnline
$cred = Get-Credential
$AdfsServer = Read-Host "Please type the name of the ADFS server"
Write-Host "Connecting to MSOnline..."
Connect-MsolService -credential:$cred
Write-Host "Setting the local ADFS server..."
Set-MSOLADFSContext -Computer:$Ad... |
PowerShellCorpus/PoshCode/Get-MailboxImportRequest.ps1 | Get-MailboxImportRequest.ps1 | # .Synopsis
# Use the Get-MailboxImportRequestProgress cmdlet to view detailed information about pst import progress.
# .Description
# The Get-MailboxImportRequestProgress cmdlet displays statistics on imports currently in progress that help determine if a import is likely to complete successfully. To accureatel... |
PowerShellCorpus/PoshCode/Set-Wallpaper (CTP3)_3.ps1 | Set-Wallpaper (CTP3)_3.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/PowerCLI 4.1.ps1 | PowerCLI 4.1.ps1 | $vmPath = "[Storage1] MyVM/MyVM.vmx"
$vm = New-VM –VMHost "192.168.1.10" –VMFilePath $vmPath -Name MyVM
# Check if there is an error and if so – handle it
if (!$?) {
if ($error[0].Exception –is [VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.DuplicateName]) {
# A VM with the same name already exists. Ch... |
PowerShellCorpus/PoshCode/chkhash_8.ps1 | chkhash_8.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-CalendarWeek_2.ps1 | Get-CalendarWeek_2.ps1 | # Get-CalendarWeek by Holger Adam
# Simple function to retrieve the calendar week to a given or the current date.
function Get-CalendarWeek {
param(
$Date = (Get-Date)
)
# get current culture object
$Culture = [System.Globalization.CultureInfo]::CurrentCulture
# retrieve calendar week
$Culture.... |
PowerShellCorpus/PoshCode/Colorize Subversion SVN_5.ps1 | Colorize Subversion SVN_5.ps1 | # detect source control management software
function findscm {
$scm = ''
:selectscm foreach ($_ in @('svn', 'hg')) {
$dir = (Get-Location).ProviderPath.trimEnd("\\")
while ($dir.Length -gt 3) {
if (Test-Path ([IO.Path]::combine(($dir), ".$_"))) {
$scm = $_
break selectscm
}
$dir =... |
PowerShellCorpus/PoshCode/Send-File.ps1 | Send-File.ps1 | ##############################################################################\n##\n## Send-File\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\nSends a file t... |
PowerShellCorpus/PoshCode/Reset SharePoint Alerts.ps1 | Reset SharePoint Alerts.ps1 | Function Reset-Alerts
{
<#
.Synopsis
Resets alerts for the specified site.
.Description
By default this resets scheduled alerts for the specified site.
This can also reset all alerts for the site and/or for a specific user.
This is inspired by: http://gallery.technet.microsoft.com/scriptcent... |
PowerShellCorpus/PoshCode/New-CodeSigningCert_2.ps1 | New-CodeSigningCert_2.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/Test-FileLock.ps1 | Test-FileLock.ps1 | filter Test-FileLock {
if ($args[0]) {$filepath = gi $(Resolve-Path $args[0]) -Force} else {$filepath = gi $_.fullname -Force}
if ($filepath.psiscontainer) {return}
$locked = $false
trap {
Set-Variable -name locked -value $true -scope 1
continue
}
$inputStream = New-Objec... |
PowerShellCorpus/PoshCode/JSON 1.7.ps1 | JSON 1.7.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
# v 1.2 - CodeSigned to make a fellow geek happy
# v 1.3 - ... |
PowerShellCorpus/PoshCode/Xml Module 6.0.ps1 | Xml Module 6.0.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/ConvertTo-CliXml.ps1 | ConvertTo-CliXml.ps1 | function ConvertTo-CliXml {
param(
[parameter(position=0,mandatory=$true,valuefrompipeline=$true)]
[validatenotnull()]
[psobject]$object
)
begin {
$type = [type]::gettype("System.Management.Automation.Serializer")
$ctor = $type.getconstructor("instance,nonpubl... |
PowerShellCorpus/PoshCode/Autoload Module 1.2.ps1 | Autoload Module 1.2.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.
## Provides significant memory benefits over pre-loading all your functions, and significant performance benefits over using plain scripts. Ca... |
PowerShellCorpus/PoshCode/16ca876b7bb7ac8c2f362b52.ps1 | 16ca876b7bb7ac8c2f362b52.ps1 | #.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
# Test-Hash npp.5.3.1.Installer.exe -HashFile npp.5.3.1.release.md5
#
# Searches the provided hash file for a line matching the "... |
PowerShellCorpus/PoshCode/New-MailBoxViaUI.ps1 | New-MailBoxViaUI.ps1 | # Requires ShowUI 1.3
function New-MailBoxViaUI {
$MailboxInfo = UniformGrid -ControlName "GetMailboxInfo" -Columns 2 {
Label "First Name:"
TextBox -Name FirstName
Label "Last Name:"
TextBox -Name "LastName"
Label "Mailbox Name:"
TextBox -Name "Name"
But... |
PowerShellCorpus/PoshCode/ASPX Mailbox (6 of 6).ps1 | ASPX Mailbox (6 of 6).ps1 | using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Net.Mail;
public partial class MailboxTaskResults : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)... |
PowerShellCorpus/PoshCode/Get-User_5.ps1 | Get-User_5.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/Email Forwarding - O365.ps1 | Email Forwarding - O365.ps1 | <#
Author: Matt Schmitt
Date: 11/28/12
Version: 1.0
From: USA
Email: ithink2020@gmail.com
Website: http://about.me/schmittmatt
Twitter: @MatthewASchmitt
Description
A script for forwarding and unforwarding email for users in Office 365.
#>
Write-Host ""
Write-Ho... |
PowerShellCorpus/PoshCode/Get-MemoryChart_2.ps1 | Get-MemoryChart_2.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-Cert.ps1 | Get-Cert.ps1 | $UsingStatements = @"
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
"@
$GetCert = @"
RemoteCertificateValidationCallback callback = delegate(
object sender,
X509Certificate cert,
X509Chain chain,
SslPoli... |
PowerShellCorpus/PoshCode/Get-RDPSettings.ps1 | Get-RDPSettings.ps1 | ########################################################################################################################
# NAME
# Get-RDPSetting
#
# SYNOPSIS
# Gets some (with filter) or all properties from a RDP file.
#
# SYNTAX
# Edit-RDP [-Path] <string> [-Name] <string> [[-Value] <object>] [-Pas... |
PowerShellCorpus/PoshCode/New-ISEMenu.ps1 | New-ISEMenu.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/Out-Wiki.ps1 | Out-Wiki.ps1 | ################################################################################
# Out-Wiki - converts cmdlets help to media wiki (wikipedia) format
# http://dmitrysotnikov.wordpress.com/2008/08/18/out-wiki-convert-powershell-help-to-wiki-format/
# Modify the invocation line at the bottom of the script to point to y... |
PowerShellCorpus/PoshCode/Get-InstalledProgram_v_1.ps1 | Get-InstalledProgram_v_1.ps1 | function Get-InstalledProgram() {
param (
[String[]]$Computer,
$User
)
if ($User -is [String]) {
$Connection = Get-Credential -Credential $User
}
if ($Connection -eq $null){
foreach ($Comp in $Computer){
$Install_soft = gwmi win32_product -ComputerName $Comp |
where {$_.vendor -notlike ... |
PowerShellCorpus/PoshCode/Set-Proxy.ps1 | Set-Proxy.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/Get-UserWithManyGroups.ps1 | Get-UserWithManyGroups.ps1 | # Lists AD users who are members in too many groups
# (c) Dmitry Sotnikov
# Details at:
# http://dmitrysotnikov.wordpress.com/2009/10/12/find-users-in-too-many-groups/
# Uses free Quest AD cmdlets
$limit = 75
Get-QADUser -SizeLimit 0 -DontUseDefaultIncludedProperties |
ForEach-Object {
$groups = Get-QAD... |
PowerShellCorpus/PoshCode/reconfigure-ha.ps1 | reconfigure-ha.ps1 | #ThePowerShellTalk
#reconfigure-ha.ps1
#take a VMhost object from the pipeline and apply the 'Reconfigure HA host' task
Process {
if ( $_ -isnot [VMware.VimAutomation.Client20.VMHostImpl] ) {
Write-Error "VMHost expected, skipping object in pipeline."
continue
}
$vmhostView = $_ | Get... |
PowerShellCorpus/PoshCode/Get-WebFile 3.6.ps1 | Get-WebFile 3.6.ps1 | ## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.6 - Add -Passthru switch to output TEXT files
## v3.5 - Add -Quiet switch to turn off the progress repo... |
PowerShellCorpus/PoshCode/List AD Attributes_2.ps1 | List AD Attributes_2.ps1 | $forest = [DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$Schema = $forest.schema
$Properties = $Schema.FindAllProperties()
foreach($property in $Properties)
{
"#################################"
"Name: {0}" -f $property.Name
"Link: {0}" -f $property.link
"LinkID: {0}" -f $prope... |
PowerShellCorpus/PoshCode/Get-BogonList_3.ps1 | Get-BogonList_3.ps1 | function Get-BogonList {
<#
.SYNOPSIS
Gets the bogon list.
.DESCRIPTION
The Get-BogonList function retrieves the bogon prefix list maintained by Team Cymru.
A bogon prefix is a route that should never appear in the Internet routing table.
A packet routed over the public Internet (not including over ... |
PowerShellCorpus/PoshCode/4a02f944-afe3-4393-b3c2-0d92d77d0b82.ps1 | 4a02f944-afe3-4393-b3c2-0d92d77d0b82.ps1 | if (Get-Process 'WRemote' -ea SilentlyContinue) {
if (Get-Process 'POS2100' -ea -ErrorAction SilentlyContinue) {
Write-Host "Restarting WinRemote"
Stop-Process -processname WRemote
Reset-Tray
#Start-Sleep -Second 2
#Invoke-Item C:\\ICOM\\POS2100\\WRemote.exe
}
else
{
Write-Ho... |
PowerShellCorpus/PoshCode/get windows product key_7.ps1 | get windows product key_7.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/Compile-Help_1.ps1 | Compile-Help_1.ps1 | # Compile-Help.ps1
# by Jeff Hillman
#
# this script uses the text and XML PowerShell help files to generate HTML help
# for all PowerShell Cmdlets, PSProviders, and "about" topics. the help topics
# are compiled into a .chm file using HTML Help Workshop.
#
# Minor tweak by John Robbins to work on x64 when lo... |
PowerShellCorpus/PoshCode/Get-OLEDBData_1.ps1 | Get-OLEDBData_1.ps1 | ###########################################################################
# Get-OLEDBData
# --------------------------------------------
# Description: This function is used to retrieve data via an OLEDB data
# connection.
#
# Inputs: $connectstring - Connection String.
# $sql ... |
PowerShellCorpus/PoshCode/Dir for days_1.ps1 | Dir for days_1.ps1 | Function Create-DatePaths {
Param (
[Parameter(Position=0,Mandatory=$True)]
[DateTime] $Start,
[Parameter(Position=1,Mandatory=$True)]
[ValidateScript({$_ -gt $Start})]
[DateTime] $End,
$DestinationPath=(Join-Path $env:UserProfile "Test")
)
0..(New-... |
PowerShellCorpus/PoshCode/Get-ExchangeDBSizes_4.ps1 | Get-ExchangeDBSizes_4.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),
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.