full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Hex dump sample.ps1 | Hex dump sample.ps1 | C:\\WINDOWS\\system32
PS > hexdmp wsock32.dll
4d 5a 90 00 03 00 00 00 04 00 MZ........
00 00 ff ff 00 00 b8 00 00 00 ..ˇˇ......
00 00 00 00 40 00 00 00 00 00 ..........
e0 00 00 00 0e 1f ba 0e 00 b4 ‡.....∫...
09 cd 21 b8 01 4c cd 21 54 68 .Õ...LÕ.Th
69 73 20 70 72 6f 67 72 61 6d is.program
20 63 61 6e 6... |
PowerShellCorpus/PoshCode/Get-LocalGroupMembership.ps1 | Get-LocalGroupMembership.ps1 | # #############################################################################
# NAME: FUNCTION-Get-LocalGroupMembership.ps1
#
# AUTHOR: Francois-Xavier Cat
# DATE: 2012/12/27
# EMAIL: fxcat@lazywinadmin.com
# WEBSITE: LazyWinAdmin.com
# TWiTTER: @lazywinadm
#
# COMMENT: This function get the local g... |
PowerShellCorpus/PoshCode/ConvertFrom-SDDL.ps1 | ConvertFrom-SDDL.ps1 | filter ConvertFrom-SDDL
{
<#
.SYNOPSIS
Convert a raw security descriptor from SDDL form to a parsed security descriptor.
Author: Matthew Graeber (@mattifestation)
.DESCRIPTION
ConvertFrom-SDDL generates a parsed security descriptor based upon any string in raw security descriptor definition l... |
PowerShellCorpus/PoshCode/Get-UIChildItem.ps1 | Get-UIChildItem.ps1 | #requires -version 2.0
[CmdletBinding()]
param($Path)
<#
Quick check to see if we have necessary module...
#>
if (!(Get-Module ShowUI)) {
try {
Import-Module ShowUI
} catch {
Write-Warning "Can't load ShowUI module. I quit! For more details about error use -Verbose parameter.... |
PowerShellCorpus/PoshCode/Run-Query (SharePoint)_4.ps1 | Run-Query (SharePoint)_4.ps1 | function Run-Query($siteUrl, $queryText)
{
[reflection.assembly]::loadwithpartialname("microsoft.sharePOint") | out-null
[reflection.assembly]::loadwithpartialname("microsoft.office.server") | out-null
[reflection.assembly]::loadwithpartialname("microsoft.office.server.search") | out-null
$s = [microsoft.share... |
PowerShellCorpus/PoshCode/ResetOutlookLivePassword.ps1 | ResetOutlookLivePassword.ps1 | function Reset-OutlookLivePassword {
<#
.SYNOPSIS
Resets an Outlook Live account password.
.DESCRIPTION
The Reset-OutlookLivePassword function resets an Outlook Live (Live@edu) acccount password.
A remote session is opened to the Outlook Live service. Connecting to the remote service requires administra... |
PowerShellCorpus/PoshCode/copy-data.ps1 | copy-data.ps1 | function copy-data {
param($source, $dest)
$counter = 0
$files = Get-ChildItem $source -Force -Recurse
foreach($file in $files)
{
$status = "Copying file {0} of {1}: {2}" -f $counter, $files.count, $file.name
Write-Progress -Activity "Copyng Files" -Status $status -PercentComplete ($counter/$files.coun... |
PowerShellCorpus/PoshCode/LibraryPrompt.ps1 | LibraryPrompt.ps1 | ##############################################################################\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\nSet-StrictMode -Version Latest\n\nfunction Prompt\n... |
PowerShellCorpus/PoshCode/Get-FSMORoleOwner_2.ps1 | Get-FSMORoleOwner_2.ps1 | Function Get-FSMORoleOwner {
<#
.SYNOPSIS
Retrieves the list of FSMO role owners of a forest and domain
.DESCRIPTION
Retrieves the list of FSMO role owners of a forest and domain
.NOTES
Name: Get-FSMORoleOwner
Author: Boe Prox
DateCreated: 06/9/2011
.EXAMPLE
... |
PowerShellCorpus/PoshCode/Set-WebConfig_1.ps1 | Set-WebConfig_1.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/PowerShell Template_7.ps1 | PowerShell Template_7.ps1 | Function new-script
{
$strName = $env:username
$date = get-date -format d
$name = Read-Host "Filename"
$email = Read-Host "eMail Address"
$file = New-Item -type file "c:\\Scripts\\$name.ps1" -force
add-content $file "#=========================================================================="
add-content $file ... |
PowerShellCorpus/PoshCode/Import-ADUser.ps1 | Import-ADUser.ps1 | #############################################################################\n##\n## Import-AdUser\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\nCreate users... |
PowerShellCorpus/PoshCode/Resolve-Aliases 1.7.ps1 | Resolve-Aliases 1.7.ps1 | #requires -version 2.0
## ResolveAliases Module v 1.6
########################################################################################################################
## Sample Use:
## Resolve-Aliases Script.ps1 | Set-Content Script.Resolved.ps1
## ls *.ps1 | Resolve-Aliases -Inplace
##############... |
PowerShellCorpus/PoshCode/New-Struct_1.ps1 | New-Struct_1.ps1 | ## New-Struct
## Creates a Struct class and emits it into memory
## The Struct includes a constructor which takes the parameters in order...
##
## Usage:
## # Assuming you have a csv file with no header and columns: artist,name,length
## New-Struct Song @{
## Artist=[string];
## Name=[string];
... |
PowerShellCorpus/PoshCode/Move-VMThin SVMotion.ps1 | Move-VMThin SVMotion.ps1 | function Move-VMThin {
PARAM(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,HelpMessage="Virtual Machine Objects to Migrate")]
[ValidateNotNullOrEmpty()]
[System.String]$VM
,[Parameter(Mandatory=$true,HelpMessage="Destination Datastore")]
[ValidateNotNullOrE... |
PowerShellCorpus/PoshCode/Robocopy Wrapper.ps1 | Robocopy Wrapper.ps1 |
function Copy-Robocopy
{
param
(
[Parameter(Position=0, Mandatory=$true)]
[String] $Source,
[Parameter(Position=1, Mandatory=$true)]
[String] $Target,
[Parameter(Position=2, Mandatory=$false)]
[String[]] $Files = @("*.*"),
[Parameter(Position=3, Mandatory=$false)]
[String] $Op... |
PowerShellCorpus/PoshCode/5a74e43a-a30a-486b-a5a6-349644cb654a.ps1 | 5a74e43a-a30a-486b-a5a6-349644cb654a.ps1 | #You'll need admin perms on all the servers to run this...
Write-Host "ComputerName in White, then Local Groups in Green, Local Groups' Members in White"
#This feeds the script a list of server names (ServerList.txt, placed in the same directory)
#for which I want the Local Groups and all those groups' Members.
... |
PowerShellCorpus/PoshCode/ESXiMgmt module sample 3.ps1 | ESXiMgmt module sample 3.ps1 | #######################################################################################################################
# File: ESXiMgmt_machines_poweroff_sample.ps1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/Backup Cisco UCS FI.ps1 | Backup Cisco UCS FI.ps1 | <#
.Synopsis
Does a backup of a single UCS target.
.Description
Uses the UCS PowerTool cmdlet 'Backup-Ucs' and does all four types of UCS backup.
Filenames include the UCS name, date/time stamp, and backup type.
The backup directory is set by a variable in the script. If it doesn't exist the scr... |
PowerShellCorpus/PoshCode/VMWare Quick Migration.ps1 | VMWare Quick Migration.ps1 | #########################################
#Name: VMWare Quick Migration Function
#Author: Justin Grote <jgrote NOSPAMAT enpointe DOT com>
#Credit: Inspired by Mike DiPetrillo's Quick Migration Script: http://www.mikedipetrillo.com/mikedvirtualization/2008/10/quick-migration-for-vmware-the-power-of-powershell.html
#... |
PowerShellCorpus/PoshCode/Get-Parameter 2.2.ps1 | Get-Parameter 2.2.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/Easy Migration Tool v3.1.ps1 | Easy Migration Tool v3.1.ps1 | #Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: Richard Yaw
# Generated On: 09/12/2010
#
# Easy Migration Script for VMware (Version 2.1)
# - Added a "Reload Tasks" feature.
# - Fixed issue with the Undo feature for S... |
PowerShellCorpus/PoshCode/Start-MyTranscript.ps1 | Start-MyTranscript.ps1 | function Start-MyTranscript
{
Param
(
[Parameter(Mandatory=$true,Position=0)]
[string] $Path
)# of Param
Process
{
$fileextension = "txt"
$filenamePrefix = [System.DateTime]::Now.ToString("yyyy-MM-dd")
$existingFiles = Get-ChildItem (Join-Path $Path "$filenamePrefix.*.Transcript.$fileextens... |
PowerShellCorpus/PoshCode/Compare-ADUserGroups.ps1 | Compare-ADUserGroups.ps1 | function Compare-ADUserGroups
{
#requires -pssnapin Quest.ActiveRoles.ADManagement
param (
[string] $FirstUser = $(Throw "SAMAccountName required."),
[string] $SecondUser = $(Throw "SAMAccountName required.")
)
$a = (Get-QADUser $FirstUser).MemberOf
$b = (Get-QADUser $SecondUser).MemberOf
$c = Comp... |
PowerShellCorpus/PoshCode/SQL Log Backup.ps1 | SQL Log Backup.ps1 | ## log backup
$backuppath = "\\\\server\\sqlbackups\\"
$alertaddress = "jrich@domain.com"
$smtp = "smtp.domain.com"
$hname = (gwmi win32_computersystem).name
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlSe... |
PowerShellCorpus/PoshCode/Get-ExchangeDBSizes.ps1 | Get-ExchangeDBSizes.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/Remove Disabled AD Users.ps1 | Remove Disabled AD Users.ps1 | import-module ActiveDIrectory
search-adaccount -searchbase "ou=UserObjectsPendingDeletion,DC=mydomain,DC=com" -Accountinactive -Timespan 400.00:00:00 | where {$_.objectclass -eq 'user'} | remove-aduser -confirm:$false
|
PowerShellCorpus/PoshCode/ESXi Config BackupScript.ps1 | ESXi Config BackupScript.ps1 | ###ESXi Configuration Backup Script
#DESCRIPION: This Script takes a CSV file with the hostname, username, and password of a list of ESXi servers, and backs up their configurations to a specified Destination
#USAGE: This script is meant to be run as a regular scheduled task or a pre-script for a backup job. There is ... |
PowerShellCorpus/PoshCode/Out-Balloon_2.ps1 | Out-Balloon_2.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 first icon of the host is used.
out-balloo... |
PowerShellCorpus/PoshCode/finddupe_13.ps1 | finddupe_13.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/LetterDiamondOneLiner v4.ps1 | LetterDiamondOneLiner v4.ps1 | &{($r=,(' '*($p=[char]$args[0]-($s=65))+[char]$s)+($p..1|%{"{0,$_} {1}{0}"-f[char]++$s,(' '*$f++)}));$r[-2..-99]}J
|
PowerShellCorpus/PoshCode/xczxc.ps1 | xczxc.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/Get_Set Signature 2.3.ps1 | Get_Set Signature 2.3.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 th... |
PowerShellCorpus/PoshCode/Out-ColorMatchInfo.ps1 | Out-ColorMatchInfo.ps1 | <#
.Synopsis
Highlights MatchInfo objects similar to the output from grep.
.Description
Highlights MatchInfo objects similar to the output from grep.
#>
#requires -version 2
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[Microsoft.PowerShell.Commands.MatchInfo] $match
)
begin {}
proc... |
PowerShellCorpus/PoshCode/Start-Presentation.ps1 | Start-Presentation.ps1 | PARAM(
$presentationTitle = "PowerShell Presentation"
, $background = "C:\\Users\\Joel\\Pictures\\flow\\Flow_2560.jpg"
)
Import-Module PowerBoots
$name = [System.Windows.Navigation.JournalEntry]::NameProperty
function global:Add-Slide {
[CmdletBinding()]
PARAM(
[Parameter(Position=0)]
$Title... |
PowerShellCorpus/PoshCode/Test-Certificate_2.ps1 | Test-Certificate_2.ps1 | #####################################################################
# Test-Certificate.ps1
# Version 0.9
#
# Tests specified certificate for certificate chain and revocation
#
# Vadims Podans (c) 2009
# http://www.sysadmins.lv/
#####################################################################
#requires -... |
PowerShellCorpus/PoshCode/Get-MIX10Video_1.ps1 | Get-MIX10Video_1.ps1 | #requires -version 2.0
PARAM (
[Parameter(Position=1, Mandatory=$true)]
[ValidateSet("wmv","wmvhigh","pptx", "mp4")]
[String]$MediaType,
[string]$Destination = $PWD
)
if( ([System.Environment]::OSVersion.Version.Major -gt 5) -and -not ( # Vista and ...
new-object Security.Principal.WindowsPrinc... |
PowerShellCorpus/PoshCode/Convert-ToCHexString_2.ps1 | Convert-ToCHexString_2.ps1 | function Convert-ToCHexString
{
param ([String] $str)
$ans = ''
[System.Text.Encoding]::ASCII.GetBytes($str) | % { $ans += "0x{0:X2}, " -f $_ }
return $ans.Trim(' ',',')
}
|
PowerShellCorpus/PoshCode/Const.ps1 | Const.ps1 | function Set-Constant {
<#
.SYNOPSIS
Creates constants.
.DESCRIPTION
This function can help you to create constants so easy as it possible.
It works as keyword 'const' as such as in C#.
.EXAMPLE
PS C:\\> Set-Constant a = 10
PS C:\\> $a += 13
Ther... |
PowerShellCorpus/PoshCode/VMWare DS Migration.ps1 | VMWare DS Migration.ps1 | #####################################################
# Migrate a VM to new storage and set to Thin Prov #
#####################################################
# Set the VM name you want to move
$Server = 'SERVERNAME'
# Set the location you want to move the VM to
$DataStore = 'DATASTORE'
# Set the vCenter name... |
PowerShellCorpus/PoshCode/WSS_MOSS export.ps1 | WSS_MOSS export.ps1 | # Export sharepoint web contents with powershell like
# stsadm -o export -url http://localhost:80/wiki -filename export.cab -overwrite -versions 1
#
# http://www.sharepointblogs.com/mossms/default.aspx
# http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.deployment.aspx
param ( [string] $sitename = "h... |
PowerShellCorpus/PoshCode/Audit Script_2.ps1 | Audit Script_2.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/Set-Computername_16.ps1 | Set-Computername_16.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/chkhash_3.ps1 | chkhash_3.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-BogonList.ps1 | Get-BogonList.ps1 | <#
.SYNOPSIS
Gets the bogon list.
.DESCRIPTION
The Get-BogonList script 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 VPNs or other tunnels) s... |
PowerShellCorpus/PoshCode/Get-Clipboard.ps1 | Get-Clipboard.ps1 | #############################################################################\n##\n## Get-Clipboard\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 th... |
PowerShellCorpus/PoshCode/ModuleWriteError.psm1.ps1 | ModuleWriteError.psm1.ps1 | ################################################################################
## Script Name: Module Write Error
## Created On: 1/7/2010
## Author: Thell Fowler
## Tribute: Joel 'Jaykul' Bennet
## File: ModuleWriteError.psm1
## Usage: import-module \\Path\\to\\module\\M... |
PowerShellCorpus/PoshCode/FormsLib.ps1 | FormsLib.ps1 | # FormsLib.ps1
# contains some helper functions to create and modify Form controls
# in a PowerShell script used by RoboGUI.ps1
#
# /\\/\\o\\/\\/
# http://thePowerShellGuy.com
Function ConvertTo-HashTable ([string]$StringValue) {
invoke-expression ("@$StringValue".replace(',',';'))
}
Function ConvertTo... |
PowerShellCorpus/PoshCode/PowerChart 0.5.ps1 | PowerChart 0.5.ps1 |
function New-PowerChart() {
[CmdletBinding(DefaultParameterSetName='DataTemplate')]
param(
[Parameter(Position=0, Mandatory=$true)]
[ValidateSet("Area","Bar","Bubble","Column","Line","Pie","Scatter")]
[String[]]
${ChartType}
,
[Parameter(Position=1, Mandatory=$true, HelpMessage='The data f... |
PowerShellCorpus/PoshCode/ping check using dotNet _1.ps1 | ping check using dotNet _1.ps1 | function dnsref ($computername) {
$ErrorActionPreference = "SilentlyContinue"
$testrun=$Null
trap {
Write-Host "ERROR: $computername does not exist in DNS" -fore Yellow
Throw $_ }
$testrun=[net.dns]::GetHostByName($computername)
if ($testrun -eq $Null){
Write-Host "No DNS Record" }
else {
foreach ($ali... |
PowerShellCorpus/PoshCode/Start-SQL 1.0.ps1 | Start-SQL 1.0.ps1 | # Start-Sql.ps1
###################################################################################################
# This is a SCRIPT which emits functions and variables into the global scope
# Most importantly, it uses a variable $SqlConnection which is expected to exist....
#
# On my computer, I set default val... |
PowerShellCorpus/PoshCode/SharePoint build script.ps1 | SharePoint build script.ps1 | #BASEPATH variable should be explicitly set in every
#build script. It represents the "root"
#of the project folder, underneath which all tools, source, config settings,
#and deployment folder lie.
$global:basepath = (resolve-path ..).path
function Set-BasePath([string]$path)
{
$global:basepath = $path
}
... |
PowerShellCorpus/PoshCode/The Letter Diamond_1.ps1 | The Letter Diamond_1.ps1 | ## Write a program which draws a diamond of the form illustrted
## below. The letter which is to appear at the widest point of the
## figure (E in the example) is to be specified as the input data.
## A
## B B
## C C
## D D
## E E
## D D
## ... |
PowerShellCorpus/PoshCode/Kill-Process_1.ps1 | Kill-Process_1.ps1 | function Kill-Process() {
param(
[string[]]$ComputerNames,
[string[]]$ProcessNames,
$User
)
###########################################################################################################
if ($ProcessNames -eq $null) {Write-Error 'The parametre "ProcessNames" cannot be empty';break}
################... |
PowerShellCorpus/PoshCode/Product key.ps1 | Product key.ps1 | function Get-SerialNumber {
$regVal = Get-ItemProperty $regDir.PSPath
$arrVal = $regVal.DigitalProductId
$arrBin = $arrVal[52..66]
$arrChr = "B", "C", "D", "F", "G", "H", "J", "K", "M", "P", "Q", "R", `
"T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9"
for ($i = 24; $i -ge 0; $i--... |
PowerShellCorpus/PoshCode/LocalAdminGUI.ps1 | LocalAdminGUI.ps1 | Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName PresentationFramework
[xml]$XAML = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="316" MinWidth="316" MaxWidth="316"
Title="Local Admins To... |
PowerShellCorpus/PoshCode/Veeam backup to OVF.ps1 | Veeam backup to OVF.ps1 | # This script runs a different OVF conversion depending on the Day of the week.
$VeeamJob = "JobName"
$server1 = 'ServerName'
asnp VMware.VimAutomation.Core -ErrorAction SilentlyContinue
asnp VeeamPSSnapin -ErrorAction SilentlyContinue
$Dest1 = "R:\\VMWARE\\OVF\\$Server1\\"
$OVFFile1 = "$($Dest1)$($Server1)... |
PowerShellCorpus/PoshCode/VI Report.ps1 | VI Report.ps1 | param( [string] $VIServer )
if ($VIServer -eq ""){
Write-Host
Write-Host "Please specify a VI Server name eg...."
Write-Host " powershell.exe Report.ps1 MYVISERVER"
Write-Host
Write-Host
exit
}
function PreReq
{
if ((Test-Path REGISTRY::HKEY_CLASSES_ROOT\\Word.Application) -eq $False){
Wr... |
PowerShellCorpus/PoshCode/DHCP Backup.ps1 | DHCP Backup.ps1 | <#
DHCP Backups Powershell Script
v1.1
2012-06-04
By VulcanX
.SYNOPSIS
This script will automate the backup of DHCP Databases and copy
them into a DFS Store at the following link:
\\\\domain.com\\DHCP
Each location has a seperate folder and once the backup... |
PowerShellCorpus/PoshCode/HttpRest 1.4.ps1 | HttpRest 1.4.ps1 | #requires -version 2.0
## HttpRest module version 1.4
####################################################################################################
## Still only the initial stages of converting to a full v2 module
## Based on the REST api from MindTouch's Dream SDK
##
## INSTALL:
## You need mindtouch.dr... |
PowerShellCorpus/PoshCode/Get-OnlineHelp_3.ps1 | Get-OnlineHelp_3.ps1 | #requires -version 2.0
## An update using New-WebServiceProxy to the MSDN ContentService instead of HttpRest
## See: http: //services.msdn.microsoft.com/ContentServices/ContentService.asmx
## YOU MUST SAVE THIS FILE AS Get-OnlineHelp.ps1 in your path, and call it as Get-OnlineHelp
## __OR__ dot-source it -- DO NO... |
PowerShellCorpus/PoshCode/finddupe_21.ps1 | finddupe_21.ps1 | 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
try
{
$stream = $file.OpenRead()
}
... |
PowerShellCorpus/PoshCode/Get-MemberBody v2.ps1 | Get-MemberBody v2.ps1 | <#
Requires ILSpy
Tested with version 2.1.0.1603
http://ilspy.net/
You'll need to adjust this to your ILSpy path
#>
[void][System.Reflection.Assembly]::LoadFrom(".\\ILSpy.exe")
function Get-MemberBody
{
[CmdletBinding()]
param(
[Parameter(ParameterSetName="MI")]
[System.... |
PowerShellCorpus/PoshCode/Get-MailboxesOverSizeLim_1.ps1 | Get-MailboxesOverSizeLim_1.ps1 | # -------------------------------------------------------------------------------
# Script: Get-MailboxesOverSizeLimit.ps1
# Author: Chris Brown
# Date: 04/04/2011 10:41:00
# Keywords:
# comments:
#
# Versioning
# 04/04/2011 CJB Initial Script
#
# ------------------------------------------------------------... |
PowerShellCorpus/PoshCode/Get-Head.ps1 | Get-Head.ps1 | function Get-Head {
#.Synopsis
# Read the first few characters of a file, fast.
param(
# The path to the file (no powershell parsing happens here)
[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[Alias("Path","PSPath")]
[String]$FilePath,
# The number of characte... |
PowerShellCorpus/PoshCode/Array-Randomizer.ps1 | Array-Randomizer.ps1 | #======================================================================================
# File Name : Array-Randomizer.ps1
# Original Author : Kenneth C. Mazie (kcmjr at kcmjr.com)
# :
# Description : Originally written to regenerate the init.txt file for server
# ... |
PowerShellCorpus/PoshCode/get-uuid_allHVs.ps1 | get-uuid_allHVs.ps1 | #The PowerShell Talk
#Building a HyperVisor Independent Script
#
#This script will take a VM (or host) object from the pipline,
#and from that determine if you're connected to XenServer
#or VMware, and return the apropriate UUID.
Begin {
#VMware VM Host (ESX) UUID
$VMHost_UUID = @{
Name = "VMHo... |
PowerShellCorpus/PoshCode/Filtering hosts.ps1 | Filtering hosts.ps1 | set-psdebug -strict
Function Where-Host
{
<#
.SYNOPSIS
Filter hosts according to hostname resolution, ping reachability or WMI capability
.DESCRIPTION
Filter hostnames by hostname resolution, ping reachbility or WMI capabilities.
Filter can be positive or negative. Positive filter includes hosts that c... |
PowerShellCorpus/PoshCode/Get-Codecs.ps1 | Get-Codecs.ps1 | [string[]]$key = "SOFTWARE\\Classes\\CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance",
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Drivers32"
function ModuleInfo([string]$path) {
$item.SubItems.Add((gci $path).VersionInfo.CompanyName)
$item.SubItems.Add((gci $path).VersionInfo.F... |
PowerShellCorpus/PoshCode/Connect-VMHost_1.ps1 | Connect-VMHost_1.ps1 | #requires -version 2
#requires -pssnapin VMware.VimAutomation.Core
Function Connect-VMHost {
<#
.Summary
Used to Connect a disconnected host to vCenter.
.Parameter VMHost
VMHost to reconnect to virtual center
.Example
Get-VMHost | Where-Object {$_.state -eq "Disconnect... |
PowerShellCorpus/PoshCode/ffdb7026-570c-4644-8a9f-b2c8fcdabfd5.ps1 | ffdb7026-570c-4644-8a9f-b2c8fcdabfd5.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/Set-Wallpaper (CTP3)_2.ps1 | Set-Wallpaper (CTP3)_2.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/ConvertFrom-Hashtable.ps1 | ConvertFrom-Hashtable.ps1 | # function ConvertFrom-Hashtable {
PARAM([[HashTable]$hashtable,[switch]$combine)
BEGIN { $output = New-Object PSObject }
PROCESS {
if($_) {
$hashtable = $_;
if(!$combine) {
$output = New-Object PSObject
}
}
$hashtable.GetEnumerator() |
ForEach-Object { Add-Member -inputObject $obje... |
PowerShellCorpus/PoshCode/Convert-BounceToX_5.ps1 | Convert-BounceToX_5.ps1 | # $Id: Convert-BounceToX500.ps1 610 2010-11-16 00:39:19Z jon $
# $Revision: 610 $
#.Synopsis
# Convert Bounce to X500
#.Description
# Convert URL Encoded address in a Bounce message to an X500 address
# that can be added as an alias to the mail-enabled object
#.Parameter bounceAddress
# URL Encoded bounce... |
PowerShellCorpus/PoshCode/O-ChristmasTree.ps1 | O-ChristmasTree.ps1 | ipmo PowerBoots
## Merry Christmas
boots {
$global:lights = @()
grid {
# A trunk
rectangle -width 20 -height 40 -fill brown -HorizontalAlignment Center -VerticalAlignment Bottom
# A perfect, triangular, tree
polygon -points { "87.5,0","0,150","175,150","87.5,0" } -margin "0,2... |
PowerShellCorpus/PoshCode/Send-HTMLFormattedEmail_7.ps1 | Send-HTMLFormattedEmail_7.ps1 | ##################################################
# cmdlets
##################################################
#-------------------------------------------------
# Send-HTMLFormattedEmail
#-------------------------------------------------
# Usage: Send-HTMLFormattedEmail -?
#------------------------------------... |
PowerShellCorpus/PoshCode/Start-ComputerJobs_1.ps1 | Start-ComputerJobs_1.ps1 | #requires -version 2.0
function Start-ComputerJobs{
<#
.NOTES
Name: Start-ComputerJobs
Author: Tome Tanasovski
Created: 6/25/2010
Modified: 6/25/2010
Version: 1.1
Website: http://powertoe.wordpress.com
.SYNOPSIS
Multithreads a scriptblock with jobs
... |
PowerShellCorpus/PoshCode/Custom Accelerators_1.ps1 | Custom Accelerators_1.ps1 | #requires -version 2.0
## Custom Accelerators for PowerShell 2
####################################################################################################
## A script module for PowerShell 2 which allows the user to create their own custom type accelerators.
## Thanks to "Oisin Grehan for the discovery":h... |
PowerShellCorpus/PoshCode/New-SQLComputerLogin.ps1 | New-SQLComputerLogin.ps1 | function New-SQLComputerLogin {
param(
[Parameter(Mandatory=$True,Position=0)]
[String]$SQLServer,
[Parameter(Mandatory=$True,Position=1)]
[String]$ComputerName,
[Switch]$Force
)
## Import-Module QAD, SQLPS -DisableNameChecking
$Computer = Get-QADComputer $ComputerName
#$NTAccountName = $Computer.NTA... |
PowerShellCorpus/PoshCode/wlanscan.ps1 | wlanscan.ps1 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=
# Name: wlanscan
# Author: Kris Cieslak (defaultset.blogspot.com)
# Date: 2010-04-03
# Description: Simple script that uses netsh to show wireless networks.
#
# Parameters: wireless interface name (optional... |
PowerShellCorpus/PoshCode/List AD Attributes.ps1 | List AD Attributes.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/Test-Server_2.ps1 | Test-Server_2.ps1 | Function Test-Server{
[cmdletBinding()]
param(
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string[]]$ComputerName,
[parameter(Mandatory=$false)]
[switch]$CredSSP,
[Management.Automation.PSCredential] $Credential)
begin{
$total = Get-Date
$results = @()
if($credssp){if(!($credential)){Wri... |
PowerShellCorpus/PoshCode/get windows product key_4.ps1 | get windows product key_4.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/Add-SqlTable_4.ps1 | Add-SqlTable_4.ps1 | try {add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" -EA Stop}
catch {add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo"}
try {add-type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8... |
PowerShellCorpus/PoshCode/Audit Script.ps1 | Audit Script.ps1 | #####################################################
# Audit script by Alan Renouf - Virtu-Al #
# Blog: http://teckinfo.blogspot.com/ #
# #
# Usage: Audit.ps1 'path' #
# ... |
PowerShellCorpus/PoshCode/DefaultParameterValues_2.ps1 | DefaultParameterValues_2.ps1 | # DefaultParameters Module
# 1.3 - fixed denable/disable, added get and remove, and improved import and set
# 1.2 - added help and commands to enable/disable the defaults
# 1.0 - initial release
function Export-DefaultParameter {
#.Synopsis
# Exports the current default parameter values
[CmdletBinding()]
par... |
PowerShellCorpus/PoshCode/Call WSPBuilder_1.ps1 | Call WSPBuilder_1.ps1 | function Run-DosCommand($program, [string[]]$programArgs)
{
write-host "Running command: $program";
write-host " Args:"
0..($programArgs.Count-1) | foreach { Write-Host " $($_): $($programArgs[$_])" }
& $program $programArgs
}
#Get-FullPath function defined elsewhere, refers to a "base directory" which all... |
PowerShellCorpus/PoshCode/ASPX Mailbox (3 of 6).ps1 | ASPX Mailbox (3 of 6).ps1 | <%@ Page Language="C#" CodeFile="MailboxConfirm.aspx.cs" AutoEventWireup="true" Inherits="MailboxConfirm" ClassName = "MailboxConfirm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="He... |
PowerShellCorpus/PoshCode/Get-WebsiteCertificate.ps1 | Get-WebsiteCertificate.ps1 | function Get-WebsiteCertificate {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)] [System.Uri]
$Uri,
[Parameter()] [System.IO.FileInfo]
$OutputFile,
[Parameter()] [Switch]
$UseSystemProxy,
[Parameter()] [Switch]
$UseDefaultCredentials,
[Parameter()] [Switch]
$TrustAllCerti... |
PowerShellCorpus/PoshCode/Import-Certificate_3.ps1 | Import-Certificate_3.ps1 | function Import-Certificate {\n<#\n .SYNOPSIS\n Imports certificate in specified certificate store.\n\n .DESCRIPTION\n Imports certificate in specified certificate store.\n\n .PARAMETER CertFile\n The certificate file to be imported.\n\n .PARAMETER StoreNames\n The certificate store(s) in which the certificate sh... |
PowerShellCorpus/PoshCode/Invoke-SqlCmd_1.ps1 | Invoke-SqlCmd_1.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/Split-Every Function.ps1 | Split-Every Function.ps1 | Function Split-Every($list, $count=4) {
$aggregateList = @()
$blocks = [Math]::Floor($list.Count / $count)
$leftOver = $list.Count % $count
for($i=0; $i -lt $blocks; $i++) {
$end = $count * ($i + 1) - 1
$aggregateList += @(,$list[$start..$end])
$start = $en... |
PowerShellCorpus/PoshCode/Invoke-Inline_1.ps1 | Invoke-Inline_1.ps1 | #############################################################################\n##\n## Invoke-Inline\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\nDemonstrates... |
PowerShellCorpus/PoshCode/PromptFor-File.ps1 | PromptFor-File.ps1 | function PromptFor-File
{
param
(
[String] $Type = "Open",
[String] $Title = "Select File",
[String] $Filename = $null,
[String[]] $FileTypes,
[switch] $RestoreDirectory,
[IO.DirectoryInfo] $InitialDirectory = $null
)
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Window... |
PowerShellCorpus/PoshCode/Resolve-Aliases 1.6.ps1 | Resolve-Aliases 1.6.ps1 | #requires -version 2.0
## ResolveAliases Module v 1.6
########################################################################################################################
## Sample Use:
## Resolve-Aliases Script.ps1 | Set-Content Script.Resolved.ps1
## ls *.ps1 | Resolve-Aliases -Inplace
##############... |
PowerShellCorpus/PoshCode/Deploy VM with Static IP_4.ps1 | Deploy VM with Static IP_4.ps1 | # 1. Create a simple customizations spec:
$custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows `
-OrgName “My Organization” -FullName “MyVM” -Domain “MyDomain” `
–DomainUsername “user” –DomainPassword “password”
# 2. Modify the default network customization settings:
$custSpec | Get-OS... |
PowerShellCorpus/PoshCode/New-SqlConnectionString.ps1 | New-SqlConnectionString.ps1 | function New-SqlConnectionString {
#.Synopsis
# Create a new SQL ConnectionString
#.Description
# Builds a SQL ConnectionString using SQLConnectionStringBuilder with the supplied parameters
#.Example
# New-SqlConnectionString -Server DBServer12 -Database NorthWind -IntegratedSecurity -MaxPoolSize 4 -Pooling
#... |
PowerShellCorpus/PoshCode/UIAutomation _1.9.ps1 | UIAutomation _1.9.ps1 | ## UI Automation v 1.10 -- REQUIRES the Reflection module
##
# WASP 2.0 is getting closer, but this is still just a preview:
# -- a lot of the commands have weird names still because they're being generated ignorantly
# -- eg: Invoke-Toggle.Toggle and Invoke-Invoke.Invoke
# v 1.7 - Fixes using multiple checks... |
PowerShellCorpus/PoshCode/PowerOracle.ps1 | PowerOracle.ps1 | # Load assembly
[System.Reflection.Assembly]::LoadWithPartialName("Oracle.DataAccess")
# Connection information
$ConnectionString = "Data Source=your_server/sid;User Id=user_name;Password=password"
#Standard SQL Query Syntax
$QueryString = "SELECT * FROM table_name WHERE #Case"
$OracleConnection = New-Objec... |
PowerShellCorpus/PoshCode/Note, open Notepad++_1.ps1 | Note, open Notepad++_1.ps1 | # Limited Notepad++ support with the simple call 'Note' So long Notepad!
function Note
{
<#
.Synopsis
Opens Notepad++
.Description
Opens Notepad++
.Parameter File
File name(s) to open, accepts wildcards. (absolute or relative path name)
.Parameter MultiInstance
Launch another Notepad++ instanc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.