full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/out-playlist.ps1 | out-playlist.ps1 |
param(
[parameter(Mandatory=$true)]
[string]
$name,
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
$file
)
begin
{
$script:files = @();
}
process
{
$script:files += $file.fullname;
}
end
{
$count = $script:files.length;
$mediaElements = $script:files | foreach{
"<media src='$... |
PowerShellCorpus/PoshCode/Backup-ModifiedGPOsv_1.1.ps1 | Backup-ModifiedGPOsv_1.1.ps1 | ###########################################################################"
#
# NAME: Backup-ModifiedGPOs.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: All Group Policy Objects modified in the specified timespan are backup up to the specified backup path.
# For more d... |
PowerShellCorpus/PoshCode/ef87bae5-0285-4381-94e0-6da00a3d4525.ps1 | ef87bae5-0285-4381-94e0-6da00a3d4525.ps1 | while($cell.value2.length -ge 0) {
$name = $cell.value2
$sam = $cell.offset(0,1).value2
$givenName = $cell.offset(0,2).value2
$surName = $cell.offset(0,3).value2
$displayName = $cell.offset(0,4).value2
$password = $cell.offset(0, 5).value2
write-host "navn:" $name "`t`t,sam:" $sam "`t,GivenName... |
PowerShellCorpus/PoshCode/DefaultParameterValues.ps1 | DefaultParameterValues.ps1 | #requires -Version 3.0
function Join-Hashtable {
param(
[Hashtable]$First,
[Hashtable]$Second,
[Switch]$Force
)
$Firsts = $First.Keys
$Output = @{} + $First
foreach($key in $Second.Keys) {
if($Firsts -notcontains $Key) {
$Output.$Key = $Second.$Key
} elseif($Force... |
PowerShellCorpus/PoshCode/User Obj ProxyAddresses.ps1 | User Obj ProxyAddresses.ps1 | Function Get-Proxy()
{
Process
{
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = "(cn=$_)"
$objSearcher.SearchScope = "Subtree"
$objUser ... |
PowerShellCorpus/PoshCode/CSV-DVS.ps1 | CSV-DVS.ps1 | $vmlist = Import-Csv toolboxesx.csv
#vsphere settings
$vsphere_server = ""
$cluster_name = ""
#dvSwitch Names to connect each side to
$prod_net = ""
$aux_net = ""
#Networks to temporarally add the vmxnet3 nics to before connecting to dvSwitch
$prod_temp_net = ""
$aux_temp_net = ""
#Folder to add VM's ... |
PowerShellCorpus/PoshCode/Get-NestedGroups v_1.ps1 | Get-NestedGroups v_1.ps1 | Function Global:Get-NestedGroups {
<#
.SYNOPSIS
Enumerate all AD group memberships of an account (including nested membership).
.DESCRIPTION
This script will return the AD group objects for each group the user is a member of.
.PARAMETER UserName
The username whose group memberships to find.
.E... |
PowerShellCorpus/PoshCode/Import-Delimited.ps1 | Import-Delimited.ps1 | ################################################################################
## Convert-Delimiter - A function to convert between different delimiters.
## E.g.: commas to tabs, tabs to spaces, spaces to commas, etc.
################################################################################
## Written pri... |
PowerShellCorpus/PoshCode/map network drive.ps1 | map network drive.ps1 | # map2_gps_prod.ps1
# Maps a network drive using PowerShell
#
#
#
#
$Drive = "O:"
$UNC = "\\\\ampwcsqlsvr2\\nam401k"
cls
# if the drive exists just remove it
if (((New-Object -Com WScript.Network).EnumNetworkDrives() | Where-Object `
{$_ -eq $Drive}))
{ # true remove drive
# Create the C... |
PowerShellCorpus/PoshCode/Convert-PowerPack2Ps_2.ps1 | Convert-PowerPack2Ps_2.ps1 | #######################################################################
# Convert-PowerPack2Ps1
#
# Converts PowerGUI .PowerPack files to ps1 PowerShell script library
# v1 - raw conversion, no name changes, only script elements converted
######################################################################
# E... |
PowerShellCorpus/PoshCode/New-GenericType.ps1 | New-GenericType.ps1 | ## New-GenericObject.ps1
## Creates an object of a generic type:
##
## Usage:
##
## # Simple generic collection
## $list = New-GenericObject System.Collections.ObjectModel.Collection System.Int32
##
## # Generic dictionary with two types
## New-GenericObject System.Collections.Generic.Dictionary System... |
PowerShellCorpus/PoshCode/Set Logfile length_2.ps1 | Set Logfile length_2.ps1 | ################################################################################
# Set-FileLines.ps1 (V 1003)
# This script will maintain the PS Transcript file (default setting), or any
# text file, at a fixed length, ie matching the number of lines entered.
# However, setting no lines will just remove any blank ... |
PowerShellCorpus/PoshCode/Backup-DatabaseObject.ps1 | Backup-DatabaseObject.ps1 | add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
add-type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
add-type -AssemblyName "Microsoft.SqlServer.SMOExtended, Version=10.0.0.0... |
PowerShellCorpus/PoshCode/HttpRest 1.0.1.ps1 | HttpRest 1.0.1.ps1 | ## Http Rest
####################################################################################################
## The first implementation of the HttpRest module, as a bunch of script functions
## Based on the REST api from MindTouch's Dream SDK
##
## INSTALL:
## You need log4net.dll mindtouch.core.dll mindto... |
PowerShellCorpus/PoshCode/Get-Netstat 1,3.ps1 | Get-Netstat 1,3.ps1 | $null, $null, $null, $null, $netstat = netstat -a -n -o
$ps = Get-Process
[regex]$regexTCP = '(?<Protocol>\\S+)\\s+(?<LAddress>\\S+):(?<LPort>\\S+)\\s+(?<RAddress>\\S+):(?<RPort>\\S+)\\s+(?<State>\\S+)\\s+(?<PID>\\S+)'
[regex]$regexUDP = '(?<Protocol>\\S+)\\s+(?<LAddress>\\S+):(?<LPort>\\S+)\\s+(?<RAddress>\\S+):(?<... |
PowerShellCorpus/PoshCode/Xml Module 6.2.ps1 | Xml Module 6.2.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/Start-Selected.ps1 | Start-Selected.ps1 | #Hightlight the name of a file or URL and this will opened or shown in browser
if ($PSVersionTable.BuildVersion.build -le 7000)
{
# PowerShell V2 CTP3
function Start-Selected
{
$ed = $psise.CurrentOpenedFile.Editor
start $ed.SelectedText
}
}
else
{
# PowerShell W7
f... |
PowerShellCorpus/PoshCode/Resolve-Error.ps1 | Resolve-Error.ps1 | #############################################################################\n##\n## Resolve-Error\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\nDisplays de... |
PowerShellCorpus/PoshCode/File Archive by Creation.ps1 | File Archive by Creation.ps1 | # ==============================================================================================
#
# NAME: FileArchivingCrTime.ps1
#
# AUTHOR: Saehrig ,Steven
# DATE : 5/19/2008
#
# COMMENT: This script will search a directory and archive files based on create time -7 days.
# for specified extension.
# =... |
PowerShellCorpus/PoshCode/Out-IseFile.ps1 | Out-IseFile.ps1 |
function Out-IseFile
{
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $True, ValueFromPipeline = $True) ]
$msg,
[Parameter(Position = 1, Mandatory = $False, ValueFromPipeline = $False)]
$path = $null,
[Parameter(Position = 2... |
PowerShellCorpus/PoshCode/Get-ChildItemRecurse.ps1 | Get-ChildItemRecurse.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/Split-String_2.ps1 | Split-String_2.ps1 | function Split-String {
#.Synopsis
# Split a string and execute a scriptblock to give access to the pieces
#.Description
# Splits a string (by default, on whitespace), and assigns it to $0, and the first 9 words to $1 through $9 ... and then calls the specified scriptblock
#.Example
# echo "this is one test ff... |
PowerShellCorpus/PoshCode/c29a0542-1603-4048-b8e2-365fa886bbcf.ps1 | c29a0542-1603-4048-b8e2-365fa886bbcf.ps1 |
function Start-ISE ()
{
<#
.synopsis
Load some file into ISE
.Description
Load some file into ISE
.Parameter fileObjOrFileName
file to be loaded
.ReturnValue
$null
.Notes
Author: bernd kriszio
e-mail: bkriszio@googlemail.com
... |
PowerShellCorpus/PoshCode/UIAutomation 1.2.ps1 | UIAutomation 1.2.ps1 | # #
# Select-Window Notepad | Remove-Window -passthru #
# ## And later ... #
# Select-Wi... |
PowerShellCorpus/PoshCode/Detect SCCM 2007.ps1 | Detect SCCM 2007.ps1 | function global:test-sccmagent {
param($PC)
[boolean]$result=get-wmiobject -Query "Select * from win32_service where Name = 'CcmExec'" -ComputerName $PC
return $result
}
|
PowerShellCorpus/PoshCode/Send-HTMLFormattedEmail_5.ps1 | Send-HTMLFormattedEmail_5.ps1 | ##################################################
# cmdlets
##################################################
#-------------------------------------------------
# Send-HTMLFormattedEmail
#-------------------------------------------------
# Usage: Send-HTMLFormattedEmail -?
#------------------------------------... |
PowerShellCorpus/PoshCode/4f560e57-408c-430b-a2c5-84a1d6d4c928.ps1 | 4f560e57-408c-430b-a2c5-84a1d6d4c928.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/VM Disk Report_1.ps1 | VM Disk Report_1.ps1 | $VMs = get-vm
$Results = @()
foreach ($VM in $VMs) {
$Result = new-object PSObject
$Result | add-member -membertype NoteProperty -name "Name" -value $VM.Name
$Result | add-member -membertype NoteProperty -name "Description" -value $VM.Notes
$VMDiskCount = 1
get-harddisk $VM | foreach {
... |
PowerShellCorpus/PoshCode/Lock-WorkStation.ps1 | Lock-WorkStation.ps1 | Function Lock-WorkStation {
$signature = @"
[DllImport("user32.dll", SetLastError = true)]
public static extern bool LockWorkStation();
"@
$LockWorkStation = Add-Type -memberDefinition $signature -name "Win32LockWorkStation" -namespace Win32Functions -passthru
$LockWorkStation::LockWorkStation() | Out-Null
}
|
PowerShellCorpus/PoshCode/Modified WOL impl_1..ps1 | Modified WOL impl_1..ps1 | function SendUdpWol {
#Packet construction reference:
#- http://wiki.wireshark.org/WakeOnLAN
#- http://en.wikipedia.org/wiki/Wake-on-LAN
#
#This code is a modified version of:
# - http://thepowershellguy.com/blogs/posh/archive/2007/04/01/powershell-wake-on-lan-script.aspx
param (
[parameter(Mandat... |
PowerShellCorpus/PoshCode/Create SP2010 Farm V_3.ps1 | Create SP2010 Farm V_3.ps1 | ############################################################################
## Create-SPFarm
## V 0.3
## Jos.Verlinde
############################################################################
Param ( [String] $Farm = "SP2010",
[String] $SQLServer = $env:COMPUTERNAME,
[String] $Passphrase = "pass@word1"... |
PowerShellCorpus/PoshCode/check-nsca.ps1 | check-nsca.ps1 | #region vars
$statvalues=("mem.usage.average", "cpu.usage.average")
$nsca_stat = ""
[int]$warnlevel = 85
[int]$criticallevel = 90
$status = ""
$nagsrv = "nagios-srv.local"
#endregion
$vms = Get-VM | Where-Object { $_.PowerState -eq "PoweredOn" } | sort-object
foreach ($vm in $vms) {
$statvalues | foreach... |
PowerShellCorpus/PoshCode/Start-Demo 3.3.1.ps1 | Start-Demo 3.3.1.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/Set-Domain_3.ps1 | Set-Domain_3.ps1 | function Set-Domain {
param( [switch]$help,
[string]$domain=$(read-host "Please specify the domain to join"),
[System.Management.Automation.PSCredential]$credential = $(Get-Crdential)
)
$usage = "`$cred = get-credential `n"
$usage += "Set-AvaDomain -domain corp.avanade.org -credential `$cred`n"
... |
PowerShellCorpus/PoshCode/Show-HtmlHelp.ps1 | Show-HtmlHelp.ps1 | ##############################################################################\n##\n## Show-HtmlHelp\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\nLaunches t... |
PowerShellCorpus/PoshCode/Invoke-RemoteCommand_1.ps1 | Invoke-RemoteCommand_1.ps1 | <#
# Script FileName: func_Invoke-RemoteCommand.ps1
# Current Version: A03
# Description: Run command on a remote computer as the currently logged on user.
# Created By: Adam Listek
# Version Notes
# A01 - Initial Release
# A02 - Conversion to Function
# A03 - Abstracted to generic purpos... |
PowerShellCorpus/PoshCode/Console Function Run.ps1 | Console Function Run.ps1 | function Run ([String]$scriptName = '-BLANK-') {
<# The next function records any running scripts started in the console
session (from $pwd) in the Scripts Event Log.
It should be placed in the Console $profile. Scripts should be started
by typing 'Run example' to capture example.ps1, for example.
The... |
PowerShellCorpus/PoshCode/New-PInvoke_1.ps1 | New-PInvoke_1.ps1 | function New-PInvoke
{
<#
.Synopsis
Generate a powershell function alias to a Win32|C api function
.Description
Creates C# code to access a C function, and exposes it via a powershell function
.Example
New-PInvoke user32 "void FlashWindow(IntPtr hwnd, bool bInvert)"
... |
PowerShellCorpus/PoshCode/Get-MyDomain.ps1 | Get-MyDomain.ps1 | Function Get-MyDomain() {
# Written by Jeremy D. Pavleck - Pavleck.NET
$IP = ((Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property IPAddress -First 1).IPAddress[0])
trap {
return "Unknown:$($IP)"
}
return [System.Net.DNS]::GetHostByAddress... |
PowerShellCorpus/PoshCode/Get-WifiNetwork.ps1 | Get-WifiNetwork.ps1 | function Get-WifiNetwork {
end {
netsh wlan sh net mode=bssid | % -process {
if ($_ -match '^SSID (\\d+) : (.*)$') {
$current = @{}
$networks += $current
$current.Index = $matches[1].trim()
$current.SSID = $matches[2].trim()
} else {
if ($_ -match '^\\s+(.*)\\... |
PowerShellCorpus/PoshCode/ISE-Comments_2.ps1 | ISE-Comments_2.ps1 | #requires -version 2.0
## ISE-Comments module v 1.1
##############################################################################################################
## Provides Comment cmdlets for working with ISE
## ConvertTo-BlockComment - Comments out selected text with <# before and #> after
## ConvertTo-BlockUn... |
PowerShellCorpus/PoshCode/Get-User_1.ps1 | Get-User_1.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/Connect-AccessDB_2.ps1 | Connect-AccessDB_2.ps1 | # Functions for connecting to and working with Access databases
# Matt Wilson
# May 2009
function Connect-AccessDB ($global:dbFilePath) {
# Test to ensure valid path to database file was supplied
if (-not (Test-Path $dbFilePath)) {
Write-Error "Invalid Access database path specified. Please supply full a... |
PowerShellCorpus/PoshCode/ScriptTransforms module_2.ps1 | ScriptTransforms module_2.ps1 | function New-ParameterTransform {
#.Synopsis
# Generates Parameter Transformation Attributes in simple PowerShell syntax
#.Description
# New-ParameterTransform allows the creation of .Net Attribute classes which can be applied to PowerShell parameters to transform or manipulate data as it's being passed in.
#.Exam... |
PowerShellCorpus/PoshCode/HTML Hardware Reports wi.ps1 | HTML Hardware Reports wi.ps1 | Function Get-HardwareReport {
[CmdletBinding()] Param
(
[parameter(Mandatory=$true,
ValueFromPipeline=$true)] [String[]]$devices
)
Begin {Write-Host " Starting Hardware Reports"}
Process {
foreach ($device in $devices) {
$name=$device
$filepath="$home\\$name.html"
$PingDevice=Test-Connection $name -count 1 -... |
PowerShellCorpus/PoshCode/Remove-DownloadFlag.ps1 | Remove-DownloadFlag.ps1 | function Set-DownloadFlag {
<#
.Synopsis
Sets the ZoneTransfer flag which marks a file as being downloaded from the internet.
.Description
Creates a Zone.Identifier alternate data stream (on NTFS file systems) and writes the ZoneTransfer marker
.Parameter Path
The file you wish to block
.Parameter Passthru
... |
PowerShellCorpus/PoshCode/JSON_1.ps1 | JSON_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
# There is no help (yet) because I'm still changing and renaming everything every time I mess with this code
# Full Round... |
PowerShellCorpus/PoshCode/List Object Discoveries_1.ps1 | List Object Discoveries_1.ps1 | # Enumerate OpsMgr 2007 Object Discoveries targeted to Windows Server
# Date: 20/10/2008
# Author: Stefan Stranger (help from Jeremy Pavleck and Marco Shaw)
# Author: Cory Delamarter (increased speed)
get-discovery | ? {$_.Target -match $(get-monitoringclass -Name "Microsoft.Windows.Server.Computer").Id} | ft Name,... |
PowerShellCorpus/PoshCode/Get-NistNtpServer_1.ps1 | Get-NistNtpServer_1.ps1 | function Get-NistNtpServer {
<#
.SYNOPSIS
Gets the list NIST NTP servers.
.DESCRIPTION
The Get-NistNtpServer function retrieves the list of NIST NTP server names, IP addresses, locations, and status.
.EXAMPLE
Get-NistNtpServer
Returns the list of NIST NTP servers.
.INPUTS
None
.OUTPUTS... |
PowerShellCorpus/PoshCode/Deploy Multiple VMs v1.1.ps1 | Deploy Multiple VMs v1.1.ps1 | #############################################################
# Deploy-VM.ps1 v1.1
# David Summers 2011/8/2
# Script to deploy VM(s) from Template(s) and set appropriate
# IP config for Windows VMs. Also sets # of CPUs, MemoryMB,
# port group, and several custom attributes.
# Moves deployed VM to specific VMs/Te... |
PowerShellCorpus/PoshCode/UIAutomation V1.ps1 | UIAutomation V1.ps1 | Add-Type -AssemblyName UIAutomationClient
Add-Type -AssemblyName UIAutomationTypes
##############################################################################################################
## REQUIRES -Module Accelerators -URI http://www.poshcode.org/762
Import-Module Accelerators
$SWA = "System.Windows.Aut... |
PowerShellCorpus/PoshCode/Get-WebFile _2.1.ps1 | Get-WebFile _2.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/Suspend-Process.ps1 | Suspend-Process.ps1 | Add-Type -Name Threader -Namespace "" -Member @"
[Flags]
public enum ThreadAccess : int
{
Terminate = (0x0001),
SuspendResume = (0x0002),
GetContext = (0x0008),
SetContext = (0x0010),
SetInformation = (0x0020),
GetInformation = (0x0040),
SetThreadToken = (0x0... |
PowerShellCorpus/PoshCode/ESXi Config Backup Scrip.ps1 | ESXi Config Backup Scrip.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/ESXiMgmt module sample _1.ps1 | ESXiMgmt module sample _1.ps1 | #######################################################################################################################
# File: ESXiMgmt_machines_poweroff_sample.ps1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/7c573254-14a1-4559-9c68-e51bc0f502b2.ps1 | 7c573254-14a1-4559-9c68-e51bc0f502b2.ps1 | [/HTML)
[Http://]
|
PowerShellCorpus/PoshCode/Send-Growl 2.0.ps1 | Send-Growl 2.0.ps1 | ## This is the first version of a Growl module (just dot-source to use in PowerShell 1.0)
## Initially it only supports a very simple notice, and I haven't gotten callbacks working yet
## Coming soon:
## * Send notices to other PCs directly
## * Wrap the registration of new messages
## * Figure out the stupid
... |
PowerShellCorpus/PoshCode/Test-QADObject.ps1 | Test-QADObject.ps1 | <#
.SYNOPSIS
Quick way to see whether the object exists in AD.
.DESCRIPTION
Returns $true if at least one object matching the criteria exists and false otherwise.
.PARAMETER Identity
Specify the DN, SID, GUID, UPN or Domain\\Name of the directory object you want to find
.EXAMPLE
PS C:\\> Test... |
PowerShellCorpus/PoshCode/Start-Countdown_1.ps1 | Start-Countdown_1.ps1 | function Start-Countdown{
<#
.Synopsis
Initiates a countdown on your session. Can be used instead of Start-Sleep.
Use case is to provide visual countdown progress during "sleep" times
.Example
Start-Countdown -Seconds 10
This method will clear the screen and display descending seconds
.Ex... |
PowerShellCorpus/PoshCode/GPPreferencesPrinters.ps1 | GPPreferencesPrinters.ps1 | ###########################################################################"
#
# NAME: GPPreferencesPrinters.psm1
#
# AUTHOR: Jan Egil Ring
# BLOG: http://blog.crayon.no/blogs/janegil
#
# COMMENT: Script module for working with shared printer connections in Group Policy Preferences.
# Contains a functi... |
PowerShellCorpus/PoshCode/Measure-Total.ps1 | Measure-Total.ps1 | #.Synopsis
# Calculate sums on top of Measure-Object
#.Description
# Pipe in objects with numerical properties, and get an extra output item
# with the sum of all the specified properties
#.Parameter Property
# The names of the properties to total
#.Example
# wc *.ps1 | total words, lines
#
# Calculates... |
PowerShellCorpus/PoshCode/TabExpansion_9.ps1 | TabExpansion_9.ps1 | ## Tab-Completion
#################
## 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<tab>
## $a = New-Object "Int32[,]" 2,3; $b = "PowerShell","Pow... |
PowerShellCorpus/PoshCode/Get-SvnInfo.ps1 | Get-SvnInfo.ps1 | Function Get-SvnInfo {
[cmdletbinding()]
Param(
[ValidateScript({Test-Path $_})]
[string]$rootDir = "C:\\Build\\",
[ValidateScript({Test-Path $_})]
[string]$buildDir = "C:\\Build\\build_dir\\",
[ValidateScript({Test-Path $_})]
[string]$outputDir = "C:\\Build\\output_dir\\",
[ValidateScript({Test-Path $_})]
... |
PowerShellCorpus/PoshCode/Compiled-Help 1.1.ps1 | Compiled-Help 1.1.ps1 | #requires -version 2.0
# 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 Robbin... |
PowerShellCorpus/PoshCode/Get-WebFile 3.7.ps1 | Get-WebFile 3.7.ps1 | ## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.7 - [int] to [long] to support files larger than 2.0 GB
## v3.6 - Add -Passthru switch to output TEXT fi... |
PowerShellCorpus/PoshCode/Disable AD Users_1.ps1 | Disable AD Users_1.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/chkhash_12.ps1 | chkhash_12.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/Update VM Tools_3.ps1 | Update VM Tools_3.ps1 | ########################################################
# Created by Brian English
# Brian.English@charlottefl.com
# eddiephoenix@gmail.com
#
# for Charlotte County Government
# No warranty suggested or implied
########################################################
# Purpose: Cycle through all VMs on a... |
PowerShellCorpus/PoshCode/Translate Service DACLS.ps1 | Translate Service DACLS.ps1 | Function Get-ServiceDACL {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
[String]$Servicename,
[Parameter(Mandatory=$false,Position=1)]
[String]$Computername= ".")
$sddl = Invoke-expression -Command "c:\\Windows\\System32\\sc.ex... |
PowerShellCorpus/PoshCode/Get-ProxyAddress.ps1 | Get-ProxyAddress.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/Take-Screenshot.ps1 | Take-Screenshot.ps1 | Function Take-ScreenShot {
<#
.SYNOPSIS
Used to take a screenshot of the desktop or the active window.
.DESCRIPTION
Used to take a screenshot of the desktop or the active window and save to an image file if needed.
.PARAMETER screen
Screenshot of the entire screen
.PARAMETER activewindow
... |
PowerShellCorpus/PoshCode/Backup AdventureWorks.ps1 | Backup AdventureWorks.ps1 | Invoke-SqlBackup -sqlserver "WIN7\\Kilimanjaro" -dbname "AdventureWorks" `
-filepath "C:\\Temp\\AdventureWorks_db_$(((Get-Date).ToString("yyyyMMddHHmm"))).bak"
|
PowerShellCorpus/PoshCode/ConvertTo-Hex_7.ps1 | ConvertTo-Hex_7.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/a83538ba-c3bf-4a64-9961-04a6b9a4f0a9.ps1 | a83538ba-c3bf-4a64-9961-04a6b9a4f0a9.ps1 | # This script supports being run with -WhatIf and -Confirm parameters.
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium')]
param (
# Regex of the states that should be included in the process killing field.
[string]$IncludeStates = '^(Disc)$', # Only DISCONNECTED sessions by default.
#... |
PowerShellCorpus/PoshCode/TruncatePath.ps1 | TruncatePath.ps1 | ###
# TruncatePath
# Version 1.0.6 (05 Nov 2008)
# Description: Replaces long provider paths in the prompt with ellipses
# Notes: Place in your profile
#
# By Mike Hays, http://www.mike-hays.net
###
$maxPathLength = 40
$showFullPath = $false
Function Prompt
{
$currentPath = (Get-Location).Path
if ( ... |
PowerShellCorpus/PoshCode/validate an IP address_4.ps1 | validate an IP address_4.ps1 | # validate given IP address as an IPAdress (given string input)
PARAM($IP=$(read-host "Enter any IP Address"))
## YOU could do this, but ...
# $IP -match "(\\d{1,3}).(\\d{1,3}).(\\d{1,3}).(\\d{1,3})" -and -not ([int[]]$matches[1..4] -gt 255)
## you shouldn't parse things yourself when it's in the framework. You... |
PowerShellCorpus/PoshCode/Backup-ModifiedGPOsv1.1.ps1 | Backup-ModifiedGPOsv1.1.ps1 | ###########################################################################"
#
# NAME: Backup-ModifiedGPOs.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: All Group Policy Objects modified in the specified timespan are backup up to the specified backup path.
# For more d... |
PowerShellCorpus/PoshCode/Get-NaShares.ps1 | Get-NaShares.ps1 | # Glenn Sizemore www . Get-Admin . Com
# Requires the NetApp OnTap SDK v3.5
#
# Will connect to the destination Filer and retrieve all cifs shares,
# and there permissions. While we can get cifs information directly
# from a filer we can't get ACL information easily. The only options
# are either RPC(too hard ... |
PowerShellCorpus/PoshCode/UIAutomation Simple 2.ps1 | UIAutomation Simple 2.ps1 | [Reflection.Assembly]::Load("UIAutomationClient, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
[Reflection.Assembly]::Load("UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
function Select-Window {
PARAM( [string]$Text="*", [switch]$Recurse,
[Syst... |
PowerShellCorpus/PoshCode/ADFS MSOL update.ps1 | ADFS MSOL 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/Invoke-Command.ps1 | Invoke-Command.ps1 | Param($file,$cmd,[switch]$whatif,[switch]$verbose)
Begin{
function Ping-Server {
Param([string]$srv)
$pingresult = Get-WmiObject win32_pingstatus -f "address='$srv'"
if($pingresult.statuscode -eq 0) {$true} else {$false}
}
$servers = @()
}
Process{
if($_)
{
... |
PowerShellCorpus/PoshCode/chkhash_15.ps1 | chkhash_15.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/Down with SOPA!.ps1 | Down with SOPA!.ps1 | <#
.Synopsis
Let's fill the logs of the US House and Senate servers with the message we don't want SOPA or E-Parasite!
.Description
Runs an while(1) loop that grabs a couple URI's from each branch's website and sleeps for 1 second between requests.
#>
# twitter tags
#occupyUSSenate
#occupyUSHouse
#sopa
#epa... |
PowerShellCorpus/PoshCode/Start-Job proxy function_1.ps1 | Start-Job proxy function_1.ps1 | <#
Example on how to use Proxy Cmdlets in combination with object events.
For more information see:
http://blog.powershell.no/2011/02/07/powershell-using-proxy-cmdlets-in-combination-with-object-events
For more information about proxy functions, see the following article on the
Microsoft PowerShell Team ... |
PowerShellCorpus/PoshCode/ConvertFrom-Property 3.7.ps1 | ConvertFrom-Property 3.7.ps1 | <#
.SYNOPSIS
Converts data from flat or single-level property files into PSObjects
.DESCRIPTION
Converts delimited string data such as .ini files, or the format-list output of PowerShell, into objects
.EXAMPLE
netsh http show sslcert | join-string "`n" |
ConvertFrom-PropertyString -ValueSeparator " ... |
PowerShellCorpus/PoshCode/ScriptTransforms module.ps1 | ScriptTransforms module.ps1 | function new-parameterTransform
{
[cmdletbinding()]
param(
[Parameter(Mandatory=$true,Position=0)]
[string] $name,
[Parameter(Mandatory=$true, Position=1)]
[scriptblock] $script
)
add-Type -TypeDefinition @"
using System;
using System.ComponentModel;
using System.Management.Automation;
... |
PowerShellCorpus/PoshCode/chkhash_4.ps1 | chkhash_4.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/Select-Random.ps1 | Select-Random.ps1 | param([array]$Collection)
begin {
$result = $Seed
if ($args -eq '-?') {
''
'Usage: Select-Random [[-Collection] <array>]'
''
'Parameters:'
' -Collection : The collection from which to select a random entry.'
' -? : Display this usa... |
PowerShellCorpus/PoshCode/Added_Deleted AD Objects_1.ps1 | Added_Deleted AD Objects_1.ps1 | #REQUIRES -pssnapin quest.activeroles.admanagement
#REQUIRES -pssnapin Pscx
begin {
# Build variables
$strSMTPServer = "192.168.xx.xx";
$strEmailFrom = "AD_Admin@yourdomain.com";
$strEmailTo = "admin@yourdomain.com";
$borders = "=" * 25;
[int]$days = -60
function TombStonedObjects {
# create Directory ... |
PowerShellCorpus/PoshCode/Find-DuplicateSMTP_1.ps1 | Find-DuplicateSMTP_1.ps1 | #######################################################################
#### Written By: Kevin Dunn ####
#### Date: 1/21/2009 ####
#### ####
#### FindDu... |
PowerShellCorpus/PoshCode/Invoke-MoveRequest_1.ps1 | Invoke-MoveRequest_1.ps1 | ###########################################################################
#
# NAME: Invoke-MoveRequest.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jer@powershell.no
#
# COMMENT: Script to use when migrating mailboxes to Microsoft Exchange Server 2010 Cross-Forest. Prepares user objects already
# moved to... |
PowerShellCorpus/PoshCode/PS2WCF_1.ps1 | PS2WCF_1.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/Add-SqlTable_5.ps1 | Add-SqlTable_5.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/VMware Daily Report_2.ps1 | VMware Daily Report_2.ps1 | # vCheck - Daily Error Report
#
# Changes:
# Version 1.12 - Added Hosts in Maintenance Mode and not responding + Bug Fixes
# Version 1.11 - Simplified mail function.
# Version 1.10 - Added How many days old the snapshots are
# Version 1.9 - Added ability to change user account which makes the WMI calls
# Versi... |
PowerShellCorpus/PoshCode/Invoke-AddTypeTypeDefini.ps1 | Invoke-AddTypeTypeDefini.ps1 | #############################################################################\n##\n## Invoke-AddTypeTypeDefinition\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/Add new smtp_set prmary_4.ps1 | Add new smtp_set prmary_4.ps1 | #alias,addnewemailaddress
import-csv .\\source.csv | foreach {
$user = Get-Mailbox $_.alias
$user.emailAddresses+= $_.addnewemailaddress
$user.primarysmtpaddress = $_.addnewemailaddress
Set-Mailbox $user -emailAddresses $user.emailAddresses
set-Mailbox $user -PrimarySmtpAddress $user.primarysmtpaddress
}
|
PowerShellCorpus/PoshCode/Yet another hex2dec.ps1 | Yet another hex2dec.ps1 | @set @script=0 /*
@echo off
set @script=
if "%1" neq "" cscript //nologo //e:jscript "%~dpnx0" %1 && goto:eof
if "%1" equ "?" cscript //nologo //e:jscript "%~dpnx0" %1 && goto:eof
setlocal
echo Hex2dec v3.07 - converts hex to decimal and vice versa
echo Copyright (C) 2012-2013 greg... |
PowerShellCorpus/PoshCode/Test-Certificate.ps1 | Test-Certificate.ps1 | #####################################################################
# Test-Certificate.ps1
# Version 0.63
#
# Tests specified certificate for certificate chain and revocation
#
# Vadims Podans (c) 2009
# http://www.sysadmins.lv/
#####################################################################
#requires ... |
PowerShellCorpus/PoshCode/Send-XmppMessage.ps1 | Send-XmppMessage.ps1 | # Download XMPP SDK from http://www.ag-software.de/index.php?page=agsxmpp-sdk
function Send-XmppMessage {
param (
$From = $( Throw "You must specify a Jabber ID for the sender." ),
$Password, # Leave blank to be prompted for password
$To = $( Throw "You must specify a Jabber ID for the recipient." ),
$Bo... |
PowerShellCorpus/PoshCode/SqlProxy_6.psm1.ps1 | SqlProxy_6.psm1.ps1 | # ---------------------------------------------------------------------------
### <Author>
### Chad Miller
### </Author>
### <Description>
### Based on functions in SQLPSX. SqlProxy.psm1 module is used for administering
### SQL Server logins, users, and roles. Designed to be used with PS Remoting.
### All actio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.