full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Read-Choice_2.ps1 | Read-Choice_2.ps1 | # function Read-Choice {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)]
[hashtable[]]$Choices
,
[Parameter(Mandatory=$False)]
[string]$Caption = "Please choose!"
,
[Parameter(Mandatory=$False)]
[string]$Message = "Choose one of the following option... |
PowerShellCorpus/PoshCode/Get-Path_1.ps1 | Get-Path_1.ps1 | function Get-Path {
[CmdletBinding(DefaultParameterSetName="DriveQualified")]
Param(
[Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("PSPath")]
[String]
$Path,
[Parameter()]
[Switch]$ResolvedPath,
[Parameter(ParameterSetName="ProviderQuali... |
PowerShellCorpus/PoshCode/Backup-ModifiedGPOs_2.ps1 | Backup-ModifiedGPOs_2.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/Invoke-Command on subnet.ps1 | Invoke-Command on subnet.ps1 | $secpasswd = ConvertTo-SecureString "here the password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("Administrator@domain", $secpasswd)
$subnet="192.168.0."
$hosts=( New-IPRange -start ($subnet + 1) -end ($subnet + 255) | Test-Online | Get-HostName | ForEach-Object { $_.Ho... |
PowerShellCorpus/PoshCode/Get-NextPrime.ps1 | Get-NextPrime.ps1 | ## Start with a seed list of primes you know:
$global:primes = 2,3,5 #,7,11,13,17,19,23
## This function will get the "next" one, add it to the list, and return it
function Get-NextPrime {
$p = $primes[-1]
while($p = $p+1){
if(!$(foreach($i in $primes) { if($p%$i-eq0) { $i } })) {
$global:prime... |
PowerShellCorpus/PoshCode/UCS_FaultReport.ps1 | UCS_FaultReport.ps1 | <#
.Synopsis
Connects to multiple UCS environments listed in a text file and generates a basic fault report for each one, then sends one email with the results. In the report are unacknowledged faults, hardware locator LEDs that are on, and if you are short on port licenses it will show that. Variables and path... |
PowerShellCorpus/PoshCode/Require-Function.ps1 | Require-Function.ps1 | function Require-Function
{
<#
.SYNOPSIS
Load function when not already loaded
.DESCRIPTION
When a function is not loaded and there is a file <functionname>.ps1 in one of the directories listed
in $env:Path it is dot sourced.
To get the function in your environment you must dot source t... |
PowerShellCorpus/PoshCode/Manual DNS Scavenging_1.ps1 | Manual DNS Scavenging_1.ps1 | #==========================================================================
#
# PowerShell Source File
#
# AUTHOR: Stephen Wheet
# NAME: dnsscavenge.ps1
# Version: 1.2
# Date: 8/12/10
#
# COMMENT:
# This script was created to manually scavenge DNS records for a given
# period. Specify the date of last r... |
PowerShellCorpus/PoshCode/Vim25 Crazy Magic.ps1 | Vim25 Crazy Magic.ps1 | cls
[void][Reflection.Assembly]::LoadWithPartialName("VMware.Vim");
# generate the proxy
$ws = New-WebServiceProxy -Uri "http://172.16.0.33/sdk/vimService?wsdl" ;
$ws.Url = "http://172.16.0.33/sdk/vimService";
$ws.UserAgent = "VMware VI Client/4.0.0";
# I modded the host to accept HTTP requests (too big o... |
PowerShellCorpus/PoshCode/Start-AtomToJabber.ps1 | Start-AtomToJabber.ps1 | ##########################################################################################
## Depends on PoshXmpp.dll from http://CodePlex.com/PowerXmpp
#requires -pssnapin PoshXmpp
##########################################################################################
# Start-AtomToChat PowerBot@im.flosoft.biz ... |
PowerShellCorpus/PoshCode/Get-Path.ps1 | Get-Path.ps1 | function Get-Path {
[CmdletBinding(DefaultParameterSetName="DriveQualified")]
Param(
[Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("PSPath")]
[String]
$Path,
[Parameter()]
[Switch]$ResolvedPath,
[Parameter(ParameterSetName="ProviderQuali... |
PowerShellCorpus/PoshCode/Set Logfile length_3.ps1 | Set Logfile length_3.ps1 | ################################################################################
# Set-FileLines.ps1 (V 1005)
# This script will maintain the PS Transcript file (default setting), or any
# text file, at a fixed length, ie matching the number of lines entered.
# However, omitting the lines parameter will just remov... |
PowerShellCorpus/PoshCode/ASP Security Flaw Detect.ps1 | ASP Security Flaw Detect.ps1 | #
# This script will help detect vulnerable configuration for the Padding Oracle
# ASP.Net vulnerability documented in MS advisory 2416728.
#
cls
function List-WebServerPaths($server_instance) {
foreach($child in $server_instance.get_Children()) {
if($child.get_SchemaClassName() -eq "IIsWebVirtualDir")
... |
PowerShellCorpus/PoshCode/Get-NistNtpServer.ps1 | Get-NistNtpServer.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, and locations.
.EXAMPLE
Get-NistNtpServer
Returns the list of NIST NTP servers.
.INPUTS
None
.OUTPUTS
PSOb... |
PowerShellCorpus/PoshCode/Set-KeepAliveTime.ps1 | Set-KeepAliveTime.ps1 | <#
.SYNOPSIS
Change the setting for TCPIP KeepAliveTime on a server or several
servers.
.DESCRIPTION
Change the setting for TCPIP KeepAliveTime on a server or several
servers.
When moving mailboxes with lar... |
PowerShellCorpus/PoshCode/Select-Random v2.2.ps1 | Select-Random v2.2.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Joel "Jaykul" Bennett
### </Author>
### <Description>
### Selects a random element from the collection either passed as a parameter or input via the pipeline.
### If the collection is passed in as an argum... |
PowerShellCorpus/PoshCode/Disable hotadd-hotplug.ps1 | Disable hotadd-hotplug.ps1 | #Script to add a value to the VMX file of a virtual client.
#This is to remove the ability to eject the network card as described in
#http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1012225
#
#Values within <> are relevant to the environment the script is run in.
#####... |
PowerShellCorpus/PoshCode/Start-Verify_1.ps1 | Start-Verify_1.ps1 | # Author: Steven Murawski http://www.mindofroot.com
# This script creates two functions (and a helper function). One starts logging all commands entered,
# and the second removes the logging.
# This script is similar to the Start-Transcript, but only logs the command line and not the output.
# Added ";" before t... |
PowerShellCorpus/PoshCode/VMWare Quick Migration_3.ps1 | VMWare Quick Migration_3.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/New-ISEScript.ps1 | New-ISEScript.ps1 | Function New-ISEScript
{
$strName = $env:username
$date = get-date -format d
$name = Read-Host "Filename"
if ($name -eq "") { $name="NewScriptTemplate_ISECommentBased" }
$synopsis = Read-Host "Synopsis"
if ($synopsis -eq "") { $synopsis="enter your synopsis of this script activity here" }
$description = Read-Ho... |
PowerShellCorpus/PoshCode/Vim25 Crazy Magic_1.ps1 | Vim25 Crazy Magic_1.ps1 | cls
[void][Reflection.Assembly]::LoadWithPartialName("VMware.Vim");
# generate the proxy
$ws = New-WebServiceProxy -Uri "http://172.16.0.33/sdk/vimService?wsdl" ;
$ws.Url = "http://172.16.0.33/sdk/vimService";
$ws.UserAgent = "VMware VI Client/4.0.0";
# I modded the host to accept HTTP requests (too big o... |
PowerShellCorpus/PoshCode/New-XVM_2.ps1 | New-XVM_2.ps1 | #Examples
<#
New-XVM -Name "WS2012-TestServer01" -SwitchName "Switch(192.168.2.0/24)" -VhdType NoVHD
New-XVM -Name "WS2012-TestServer02" -SwitchName "Switch(192.168.2.0/24)" -VhdType ExistingVHD -VhdPath 'D:\\vhds\\WS2012-TestServer02.vhdx'
New-XVM -Name "WS2012-TestServer03" -SwitchName "Switch(192.168.2.0/24)" ... |
PowerShellCorpus/PoshCode/Reflection Module 4.5.ps1 | Reflection Module 4.5.ps1 | #requires -version 2.0
# ALSO REQUIRES Autoload for some functionality (Latest version: http://poshcode.org/3173)
# You should create a Reflection.psd1 with the contents:
# @{ ModuleToProcess="Reflection.psm1"; RequiredModules = @("Autoload"); GUID="64b5f609-970f-4e65-b02f-93ccf3e60cbb"; ModuleVersion="4.5.0.0" ... |
PowerShellCorpus/PoshCode/Restart-IISAppPool.ps1 | Restart-IISAppPool.ps1 | function Restart-IISAppPool {
[CmdletBinding(SupportsShouldProcess=$true)]
#.Synopsis
# Restarts an IIS AppPool
#.Parameter ComputerName
# The name of a web server to restart the AppPool on
#.Parameter Pool
# The name of the AppPool to recycle (if you include wildcards, results in an init... |
PowerShellCorpus/PoshCode/Select w_ subproperties.ps1 | Select w_ subproperties.ps1 | <#
This is a proxy function enhancing Select-Object by adding the
ability to use subproperties in the Property parameters.
For example:
Set-Process | Select-Object ProcessName, StartTime.DayOfWeek
This is the only changed behavior (properties with dots
get evaluated as expressions) - everythin... |
PowerShellCorpus/PoshCode/Set-FT.ps1 | Set-FT.ps1 | #Some Parameters
param([string]$ftVM, [string]$ftState)
#Load the PowerCLI Snapin
add-pssnapin VMware.VimAutomation.Core
#Load the creds file
$creds = Get-VICredentialStoreItem -file c:\\test
#Connect to the host
connect-viserver -Server $creds.Host -User $creds.User -Password $creds.Password
#Based on... |
PowerShellCorpus/PoshCode/New-NamedPipe.ps1 | New-NamedPipe.ps1 | # .NET 3.5 is required to use the System.IO.Pipes namespace
[reflection.Assembly]::LoadWithPartialName("system.core") | Out-Null
$pipeName = "pipename"
$pipeDir = [System.IO.Pipes.PipeDirection]::InOut
$pipe = New-Object system.IO.Pipes.NamedPipeServerStream( $pipeName, $pipeDir )
|
PowerShellCorpus/PoshCode/Get-OLEDBData.ps1 | Get-OLEDBData.ps1 | ###########################################################################
# Get-OLEDBData
# --------------------------------------------
# Description: This function is used to retrieve data via an OLEDB data
# connection.
#
# Inputs: $connectstring - Connection String.
# $sql ... |
PowerShellCorpus/PoshCode/Colorize Subversion SVN_4.ps1 | Colorize Subversion SVN_4.ps1 | # detect source control management software
function findscm {
$scm = ''
:selectscm foreach ($_ in @('svn', 'hg')) {
$dir = (Get-Location).Path
while ($dir.Length -gt 3) {
if (Test-Path ([IO.Path]::combine($dir, ".$_"))) {
$scm = $_
break selectscm
}
$dir = $dir -Replace '\\\\[^\\\\]+$'... |
PowerShellCorpus/PoshCode/Get-AliasSuggestion.ps1 | Get-AliasSuggestion.ps1 | ##############################################################################\n##\n## Get-AliasSuggestion\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nGet ... |
PowerShellCorpus/PoshCode/Get-PrinterInfo_1.ps1 | Get-PrinterInfo_1.ps1 | $strComputer = "PrinterName"
$Ports = get-wmiobject -class "win32_tcpipprinterport" -namespace "root\\CIMV2" -computername $strComputer
$Printers = get-wmiobject -class "Win32_Printer" -namespace "root\\CIMV2" -computername $strComputer
$ports | Select-Object Name,Hostaddress | Set-Variable port
$Printers | Select-... |
PowerShellCorpus/PoshCode/Get VMware Information.ps1 | Get VMware Information.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.Ce... |
PowerShellCorpus/PoshCode/Script-Proc_1.sql.ps1 | Script-Proc_1.sql.ps1 | #Copyright (c) 2011 Justin Dearing
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, dist... |
PowerShellCorpus/PoshCode/Get-ProcessCount.ps1 | Get-ProcessCount.ps1 | # Get-ProcessCount uses 2 main variables, server and process name.
# Process name is typically the end exe, such as "svchost.exe"
# Will accept unnamed args (Get-ProcessCount servername processname)
# or named args (Get-ProcessCount -Computer servername -Process processname)
Function Get-ProcessCount([string]$proce... |
PowerShellCorpus/PoshCode/Get-Sysinternals_2.ps1 | Get-Sysinternals_2.ps1 |
function Get-SysInternals {
param ( $sysIntDir=(join-path $env:systemroot "\\Sysinternals\\") )
if(!(Test-Path -Path $sysIntDir -PathType Container))
{
$null = New-Item -Type Directory -Path $sysIntDir -Force
}
$log = join-path $sysIntDir "changes.log"
Add-Content ... |
PowerShellCorpus/PoshCode/Get-NTStatusException.ps1 | Get-NTStatusException.ps1 | function Get-NTStatusException
{
<#
.SYNOPSIS
Resolves an NTSTATUS error code.
Author: Matthew Graeber (@mattifestation)
.DESCRIPTION
Get-NTStatusException returns a friendly error message based on the NTSTATUS code passed in. This function is useful when interacting with Windows Native API functions wit... |
PowerShellCorpus/PoshCode/Install-Solarized_1.ps1 | Install-Solarized_1.ps1 | [CmdletBinding()]
param($Path = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Accessories\\Windows PowerShell\\Windows PowerShell.lnk" )
# SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B RGB HSB
# --------- ------- ---- ------- ----------- ---------- ----------- -----------
... |
PowerShellCorpus/PoshCode/PSTUtility_2.psm1.ps1 | PSTUtility_2.psm1.ps1 | #=============================================================================
#
# PST Utilities - For Discovery, Import, Removal
#
# Dan Thompson
# dethompson71 at live dot com
#
# This collection of tools for importing PSTs has been pieced together
# over many months of trial and error.
#
# Goal is to get ... |
PowerShellCorpus/PoshCode/Windows Startup Script_1.ps1 | Windows Startup Script_1.ps1 | <#======================================================================================
File Name : Startup.ps1
Original Author : Kenneth C. Mazie
:
Description : This is a Windows startup script with pop-up notification and checks to
: assure things are no... |
PowerShellCorpus/PoshCode/Logoff all users_2.ps1 | Logoff all users_2.ps1 | function RemoveSpace([string]$text) {
$private:array = $text.Split(" ", `
[StringSplitOptions]::RemoveEmptyEntries)
[string]::Join(" ", $array) }
$quser = quser
foreach ($sessionString in $quser) {
$sessionString = RemoveSpace($sessionString)
$session = $sessionString.split()
i... |
PowerShellCorpus/PoshCode/Call WSPBuilder.ps1 | Call WSPBuilder.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 allows me... |
PowerShellCorpus/PoshCode/ESX host NTP Settings.ps1 | ESX host NTP Settings.ps1 | <#======================================================================================
File Name : ESX-NTP.ps1
Original Author : Kenneth C. Mazie
:
Description : This is a VMware PowerCLI script for synchronizing NTP settings across
: all ESX hosts in a Vi... |
PowerShellCorpus/PoshCode/ModuleWriteError_1.psm1.ps1 | ModuleWriteError_1.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/LibraryChart_1.ps1 | LibraryChart_1.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller
### </Author>
### <Description>
### Defines functions for wokring with Microsoft Chart Control for .NET 3.5 Framework
### Pipe output of Powershell command to Out-Chart function and specify c... |
PowerShellCorpus/PoshCode/Get-HttpResponseUri.ps1 | Get-HttpResponseUri.ps1 | function Get-HttpResponseUri {
#.Synopsis
# Fetch the HEAD for a url and return the ResponseUri.
#.Description
# Does a HEAD request for a URL, and returns the ResponseUri. This is useful for resolving (in a service-independent way) shortened urls.
#.Parameter ShortUrl
# A (possibly) shortened URL to be res... |
PowerShellCorpus/PoshCode/8097adfd-db82-4ae1-8996-c504851508d5.ps1 | 8097adfd-db82-4ae1-8996-c504851508d5.ps1 | #==========================================================================
# NAME: getunknownsids.ps1
#
# AUTHOR: Stephen Wheet
# Version: 4.0
# Date: 6/11/10
#
# COMMENT:
# This script was created to find unknown SIDs or old domain permissions
# on folders. It ignores folders where inheirtance is turned ... |
PowerShellCorpus/PoshCode/Easy Migration Tool v_2.1.ps1 | Easy Migration Tool v_2.1.ps1 | #Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: Richard Yaw
# Generated On: 07/12/2011
#
# Easy Migration Script for VMware (Version 2.0)
# - Added a "Reload Tasks" feature.
# - Fixed issue with the Undo feature for S... |
PowerShellCorpus/PoshCode/Deleted-Objects.ps1 | Deleted-Objects.ps1 | param (
$Computer,
[String[]]$ObjectsDeleted
)
$Info = $null
$Disks = $null
trap {Write-Host "Error WmiObject $Computer";Continue}
$Disks += Get-WmiObject win32_logicaldisk -ComputerName $Computer |
Where-Object {$_.Size -ne $null}
foreach ($Disk in $Disks){
if ($Disk.Name -like "*:*") {
$Dis... |
PowerShellCorpus/PoshCode/New-AdUser.ps1 | New-AdUser.ps1 | function New-AdUser {
param (
[string] $Username = $(throw "Parameter -Username [System.String] is required."),
[string] $Password = $(throw "Parameter -Password [System.String] is required."),
[string] $OrganizationalUnit = "Users",
[string] $DisplayName,
[string] $Fir... |
PowerShellCorpus/PoshCode/Reverse filename sequenc_4.ps1 | Reverse filename sequenc_4.ps1 | # Reverse filename sequence v 0.9
# Author: Sean Wendt
#
# This script will rename a sequenced set of files in a directory.
# For example, you have foobar01.jpg, foobar02.jpg, foobar03.jpg
# -- it will reverse the order, so the last file is now 01, the second to last 02, etc..
#
# Limitations: -You cannot us... |
PowerShellCorpus/PoshCode/LDAPLogging.ps1 | LDAPLogging.ps1 | \nfunction Private:Configure-Logging {\n Use one of the following aliases:\n Get-LDAPLogging\n View current LDAP logging settings\n Enable-LDAPLogging\n Enables LDAP logging. Logging is set to log every single LDAP query and stores it in directory services log.\n Disabl... |
PowerShellCorpus/PoshCode/num.ps1 | num.ps1 | ## SVN STAT colorizer - http://www.overset.com/2008/11/18/colorized-subversion-svn-stat-powershell-function/
function ss () {
$c = @{ "A"="Magenta"; "D"="Red"; "C"="Yellow"; "G"="Blue"; "M"="Cyan"; "U"="Green"; "?"="DarkGray"; "!"="DarkRed" }
foreach ( $svno in svn stat ) {
if ( $c.ContainsKey($svno.ToString(... |
PowerShellCorpus/PoshCode/e0d5c1ac-138e-4921-8f14-f59a45084096.ps1 | e0d5c1ac-138e-4921-8f14-f59a45084096.ps1 | [string]$entry = $args[0]
if ($entry -eq $null) { [string]$entry = Read-Host -Prompt "Enter Computer Name" }
$Computers = Get-QADComputer $entry
$Computers | ForEach-Object {Get-WmiObject Win32_Registry -ComputerName $_.Name | Select-Object @{Name="Name";Expression={$_.__SERVER}},CurrentSize,MaximumSize,Caption}... |
PowerShellCorpus/PoshCode/WSUS Admin Module_1.ps1 | WSUS Admin Module_1.ps1 | Write-Host "`n"
Write-Host "`t`tWSUS Administrator Module 1.0"
Write-Host "`n"
Write-Host -nonewline "Make initial connection to WSUS Server:`t"
Write-Host -fore Yellow "Connect-WSUSServer"
Write-Host -nonewline "Disconnect from WSUS Server:`t`t"
Write-Host -fore Yellow "Disconnect-WSUSServer"
Write-Host ... |
PowerShellCorpus/PoshCode/Get-ChildItemColor_1.ps1 | Get-ChildItemColor_1.ps1 | function Get-ChildItemColor {
<#
.Synopsis
Returns childitems with colors by type.
.Description
This function wraps Get-ChildItem and tries to output the results
color-coded by type:
Compressed - Yellow
Directories - Dark Cyan
Executables - Green
Text Files - Cyan
Others - Default
.ReturnVal... |
PowerShellCorpus/PoshCode/Asp_1.net-Using httpConext.ps1 | Asp_1.net-Using httpConext.ps1 | Default.aspx
----------------
Partial Class _Default
Inherits System.Web.UI.Page
Dim var1 As String
Dim var2 As String
Protected Sub lnk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk.Click
Context.Items("Nome") = var1
Context.Items("Email") = var2
Server.Transfer("pagina3.as... |
PowerShellCorpus/PoshCode/Get-InstalledProgram_v4.ps1 | Get-InstalledProgram_v4.ps1 | param (
[String[]]$Computer,
$User
)
#############################################################################################
if ($User) {$Connection = Get-Credential -Credential $User}
#############################################################################################
if (!$Connection){
foreach... |
PowerShellCorpus/PoshCode/hex2dec.ps1 | hex2dec.ps1 | @echo off
::unequal symbols
for %%i in ("!", "x") do if "%1" equ "%%~i" goto:error
::display help information args
for %%i in ("-h", "/h", "-help", "/help") do (
if "%1" equ "%%~i" goto:help
)
if "%1" equ "-?" goto:help
if "%1" equ "/?" goto:help
::interactive mode
if "%1" equ "" (
if not defi... |
PowerShellCorpus/PoshCode/PowerBot _1.0.ps1 | PowerBot _1.0.ps1 | ## This script requires ...\\WindowsPowerShell\\Libraries\\Meebey.SmartIrc4net.dll
## You can get Meebey.SmartIrc4net.dll from
## http://voxel.dl.sourceforge.net/sourceforge/smartirc4net/SmartIrc4net-0.4.0.bin.tar.bz2
## And the docs are at http://smartirc4net.meebey.net/docs/0.4.0/html/
##########################... |
PowerShellCorpus/PoshCode/Format-String.ps1 | Format-String.ps1 | ##############################################################################\n##\n## Format-String\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\nReplaces t... |
PowerShellCorpus/PoshCode/Test-TCPPort_1.ps1 | Test-TCPPort_1.ps1 | function Test-TCPPort {
param (
[parameter(Mandatory=$true)]
[string] $ComputerName,
[parameter(Mandatory=$true)]
[string] $Port
)
try {
$TimeOut = 5000
$IsConnected = $false
$Addresses = [System.Net.Dns]::GetHostAddresses($ComputerName) | ? {$_.AddressFamily -eq 'InterNetwork'}
$Ad... |
PowerShellCorpus/PoshCode/Create SP2010 Farm V_2.ps1 | Create SP2010 Farm V_2.ps1 | ############################################################################
## Create-SPFarm
## V 0.3
## Jos.Verlinde
############################################################################
Param ( [String] $Farm = "SP2010",
[String] $SQLServer = $env:COMPUTERNAME,
[String] $Passphrase = "pass@word1"... |
PowerShellCorpus/PoshCode/Pause-Script & Out-More.ps1 | Pause-Script & Out-More.ps1 | # Pause-Script
#
# Pauses execution until a key is pressed.
function Pause-Script {
param([string]$message = 'Press any key to continue...')
Write-Host -NoNewLine $message
$null = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
Write-Host ""
}
# Out-More
#
# Displays one window's worth of data... |
PowerShellCorpus/PoshCode/Logger.psm1 0.5.ps1 | Logger.psm1 0.5.ps1 | <#
Name : Universal NLog Logging Module (NLog.psm1)
Version : 0.5
Author : Joel Bennett (MVP)
Site : http://www.HuddledMasses.org/
Version History:
0.5 - Port to NLog from Log4Net ( http://nlog-project.org )
Include support for Growl plugin for NLog, but left out the rotat... |
PowerShellCorpus/PoshCode/5f5f41e1-5b7f-46e6-a165-083c18a8ea02.ps1 | 5f5f41e1-5b7f-46e6-a165-083c18a8ea02.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/ConvertFrom-CliXml_1.ps1 | ConvertFrom-CliXml_1.ps1 |
function ConvertFrom-CliXml {
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[String[]]$InputObject
)
begin
{
$OFS = "`n"
[String]$xmlString = ""
}
process
{
$xmlString += $InputObje... |
PowerShellCorpus/PoshCode/Create SP2010 Farm V_1.ps1 | Create SP2010 Farm V_1.ps1 | ############################################################################
## Create-SPFarm
## V 0.3
## Jos.Verlinde
############################################################################
Param ( [String] $Farm = "SP2010",
[String] $SQLServer = $env:COMPUTERNAME,
[String] $Passphrase = "pass@word1"... |
PowerShellCorpus/PoshCode/Get-WootDeal.ps1 | Get-WootDeal.ps1 | <#
.Synopsis
Gets the daily woot deal from woot.com.
.Description
Gets product description and price of the daily woot deal from the woot.com website.
.Outputs
Custom object containing two (2) NoteProperties: Product and Price.
.Parameter URL
... |
PowerShellCorpus/PoshCode/FTP Upload Dir Tree.ps1 | FTP Upload Dir Tree.ps1 | function upload-directory {
param( [string] $server = $( Throw "You must specify an FTP server to logon to."),
[string] $dir = $( Throw "You must specify a local directory to upload (ie, C:\\Testing\\FTPTest\\)"),
[switch] $overwrite = $false,
[System.Management.Automation.PSCredential] $cred = $( Throw "Yo... |
PowerShellCorpus/PoshCode/Shift Operators.ps1 | Shift Operators.ps1 | #requires -version 2.0 ## for v1 you need to change Add-Type to "New-Type":http://poshcode.org/720
Add-Type @"
public class Shift {
public static int Left(int x, int count) { return x >> count; }
public static uint Left(uint x, int count) { return x >> count; }
public static long Left(long x, ... |
PowerShellCorpus/PoshCode/Get-Constructor.ps1 | Get-Constructor.ps1 | # Eg: Get-Constructor System.IO.StreamReader
function Get-Constructor {
Param([Type]$type)
$OFS = ", "
$Type.GetConstructors("Public,Instance,Static") |
ForEach-Object { "{0}( {1} )" -f $_.DeclaringType, "$($_.GetParameters() | %{ $_.ParameterType })" }
}
|
PowerShellCorpus/PoshCode/chkhash_22.ps1 | chkhash_22.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/ConvertTo-Icon.ps1 | ConvertTo-Icon.ps1 | [Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null
#Version History
#v1.0 - Chad Miller - Initial release
#Converts Image Files to icon files
#Adapted from WinForm C# code by Haresh Ambaliya
#http://code.msdn.microsoft.com/Convert-Image-file-to-Icon-c927d9f7
function ConvertTo-Icon
{... |
PowerShellCorpus/PoshCode/Get-Parameter_2.ps1 | Get-Parameter_2.ps1 | param($Cmdlet) foreach ($paramset in (Get-Command $Cmdlet).ParameterSets) {
$Output = @()
foreach ($param in $paramset.Parameters) {
$process = "" | Select-Object Name, ParameterSet, Aliases, IsMandatory, CommonParameter
$process.Name = $param.Name
if ( $paramset.name -eq "__AllParameterSets" ) { $process.... |
PowerShellCorpus/PoshCode/ExportSQLDeadlockGraphs.ps1 | ExportSQLDeadlockGraphs.ps1 | <#
ALZDBA SQLServer_Export_DeadlockGraphs_SMO.ps1
Export top n Deadlock graphs for all databases of a given SQLServer (SQL2008+) Instance
results in a number of .XDL files and one overview file *AllDbDeadlockGraphs.csv.
Double clicking an .XDL file will open the graphical representation of the deadlock info in SQ... |
PowerShellCorpus/PoshCode/192.168.1.1.ps1 | 192.168.1.1.ps1 | function Set-IPAddress {
param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"),
[string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"),
[string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"),
[string]$gateway = $(read-host "Enter... |
PowerShellCorpus/PoshCode/Copy Files Log to Excel.ps1 | Copy Files Log to Excel.ps1 | # Get User/Pass
$Cred = Get-Credential
# Add Quest CMDLETS
Add-PSSnapin Quest.ActiveRoles.ADManagement -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
# Get Computer's from AD
$Computers = Get-QADComputer -SearchRoot "OU=Workstations,DC=Domain,DC=com" -Credential $Cred
# Import BITS for the file tra... |
PowerShellCorpus/PoshCode/Update VM Tools_2.ps1 | Update VM Tools_2.ps1 | ########################################################
# Created by Brian English
# for Charlotte County Government
# No warranty suggested or implied
########################################################
########################################################
#connect to VirtualCenter server (i.e. virtua... |
PowerShellCorpus/PoshCode/MetroApps Module.ps1 | MetroApps Module.ps1 | <#
Created by: Tome Tanasovski
Version: 1.0
Date: 11/2/2012
This module provides two functions:
Get-MetroApp - This cmdlet reads the registry for the keys that have the launcher id and the entry point (interesting for xaml apps, but not so much for html5 apps)
Start-MetroApp - This cmdlet uses one of the id... |
PowerShellCorpus/PoshCode/New-XVM_1.ps1 | New-XVM_1.ps1 | #Examples
<#
New-XVM -Name "WS2012-TestServer01" -SwitchName "Switch(192.168.2.0/24)" -VhdType NoVHD
New-XVM -Name "WS2012-TestServer02" -SwitchName "Switch(192.168.2.0/24)" -VhdType ExistingVHD -VhdPath 'D:\\vhds\\WS2012-TestServer02.vhdx'
New-XVM -Name "WS2012-TestServer03" -SwitchName "Switch(192.168.2.0/24)" ... |
PowerShellCorpus/PoshCode/Get-RecurseMember_2.ps1 | Get-RecurseMember_2.ps1 | function Get-RecurseMember {
<#
.Synopsis
Does a recursive search for unique users that are members of an AD group.
.Description
Recursively gets a list of unique users that are members of the specified
group, expanding any groups that are members out into their member users.
Note: Requires the Ques... |
PowerShellCorpus/PoshCode/Snippet Compiler_1.ps1 | Snippet Compiler_1.ps1 | #Require 2.0
$def = [Environment]::CurrentDirectory
##################################################################################################
$mnuOpen_Click= {
(New-Object Windows.Forms.OpenFileDialog) | % {
$_.FileName = "source"
$_.Filter = "C# (*.cs)|*.cs"
$_.InitialDirectory = $d... |
PowerShellCorpus/PoshCode/Invoke-NamedParameter_1.ps1 | Invoke-NamedParameter_1.ps1 | Function Invoke-NamedParameter {
<#
.SYNOPSIS
Invokes a method using named parameters.
.DESCRIPTION
A function that simplifies calling methods with named parameters to make it easier to deal with long signatures and optional parameters. This is particularly helpful for COM objects.
.PARAMETER Object
... |
PowerShellCorpus/PoshCode/FuncionInfo_2.types.ps1xml.ps1 | FuncionInfo_2.types.ps1xml.ps1 | <?xml version="1.0" encoding="utf-8" ?>
<Types>
<Type>
<Name>System.Management.Automation.FunctionInfo</Name>
<Members>
<ScriptProperty>
<Name>Verb</Name>
<GetScriptBlock>
if ($this.Name.Contains("-")) {
$this.Name.Substring(0,$this.Name.Indexof("-"))
} else {
$null
... |
PowerShellCorpus/PoshCode/Get-MachineStartupShutdo.ps1 | Get-MachineStartupShutdo.ps1 | ##############################################################################\n##\n## Get-MachineStartupShutdownScript\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYN... |
PowerShellCorpus/PoshCode/Get-MySqlDataSet.ps1 | Get-MySqlDataSet.ps1 | # Get-MySQLDataSet - Query a MySQL server & return the result to a PoSh variable
# Created: 11/29/07 Modified: 11/29/07
# Written by: Matt Wilson (Kemis / Matt at ClearChoiceIT dot com) with MAJOR help from
# Joel Bennett (Jaykul): http://powershellcentral.com/scripts/57
# Andrew Dashin: http://andrewdashin.co... |
PowerShellCorpus/PoshCode/Fisher-Yates shuffle.ps1 | Fisher-Yates shuffle.ps1 | function Shuffle
{
param([Array] $a)
$rnd=(new-object System.Random)
for($i=0;$i -lt $a.Length;$i+=1){
$newpos=$i + $rnd.Next($a.Length - $i);
$tmp=$a[$i];
$a[$i]=$a[$newpos];
$a[$newpos]=$tmp
}
return $a
}
|
PowerShellCorpus/PoshCode/Alias latest msbuild.ps1 | Alias latest msbuild.ps1 | ## Because of Split-Path, I get the "Framework" folder path (one level above the versioned folders)
$rtr = Split-Path $([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory())
## Then I loop through them in ascending (numerical, but really ascii) order
## each time I find installutil or mdbuild... |
PowerShellCorpus/PoshCode/GPRS Online log.ps1 | GPRS Online log.ps1 | ################################################################################
# Get-GprsTime.ps1(V 1008)
# Check the total connect time of any GPRS devices from a specified date.
# Use the -Verbose switch for some extra information if desired. A default value
# can be set with the -Monthly switch but can ... |
PowerShellCorpus/PoshCode/ConvertFrom-FahrenheitWi_2.ps1 | ConvertFrom-FahrenheitWi_2.ps1 | ## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
param([double] $Fahrenheit)
Set-StrictMode -Version Latest
## Convert Fahrenheit to Celsius
function ConvertFahrenheitToCelsius([double] $fahrenheit)
{
$celsius = $fahrenheit - 32
$celsius = $celsius /... |
PowerShellCorpus/PoshCode/New-TestDataSet.ps1 | New-TestDataSet.ps1 | ## Generate a dummy dataset for testing
Param(
$path = $pwd,
$files = $(ls $path)
)
$global:dt = New-Object system.data.datatable "datatable"
$global:ds = New-Object system.data.dataset "dataset"
$null = $ds.Tables.Add( $dt )
$global:cols = ls | where {!$_.PsIsContainer} |
Get-Member -type Propert... |
PowerShellCorpus/PoshCode/finddupe_16.ps1 | finddupe_16.ps1 | function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]'))
{
$stream = $null;
$cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider];
$hashAlgorithm = new-object $cryptoServiceProvider
$stream = $file.OpenRead();
$hashByteArray = $hashA... |
PowerShellCorpus/PoshCode/validate an IP address.ps1 | validate an IP address.ps1 | # validate given IP address in $ip1 variable
$ip1 = "192.168.22.455"
($ip1.split(".") | where-object { $_ -ge 1 -and $_ -le 255 } | Where-Object { $_ -match "\\d{1,3}"} | Measure-Object).count -eq 4
|
PowerShellCorpus/PoshCode/HP_Plink_ISO.ps1 | HP_Plink_ISO.ps1 | $plink = plink -ssh Administrator@$ILOIP -pw $PSWD -auto_store_key_in_cache "set /map1/oemhp_vm1/cddr1 oemhp_image=http://IPADDRESS/ISO.iso"
$plink = plink -ssh Administrator@$ILOIP -pw $PSWD -auto_store_key_in_cache "set /map1/oemhp_vm1/cddr1 oemhp_boot=connect"
$plink = plink -ssh Administrator@$ILOIP -pw $PSWD -au... |
PowerShellCorpus/PoshCode/Get Twitter RSS Feed_9.ps1 | Get Twitter RSS Feed_9.ps1 | param ([String] $ScreenName)
$client = New-Object System.Net.WebClient
$idUrl = "https://api.twitter.com/1/users/show.json?screen_name=$ScreenName"
$data = $client.DownloadString($idUrl)
$start = 0
$findStr = '"id":'
do {
$start = $data.IndexOf($findStr, $start + 1)
if ($start -gt 0) {
$s... |
PowerShellCorpus/PoshCode/Convert-CBZ2CBR.ps1 | Convert-CBZ2CBR.ps1 | ###########################################################################
#
# NAME: Convert-CBZ2CBR.ps1
#
# AUTHOR: Neiljmorrow
# EMAIL: Neiljmorrow@gmail.com
#
# NOTE: Written to use command line version of 7zip (http://7zip.com)
# from the default install location. Please modify the path below
# if necessa... |
PowerShellCorpus/PoshCode/Search-Registry.ps1 | Search-Registry.ps1 | ##############################################################################\n##\n## Search-Registry\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\nSearch t... |
PowerShellCorpus/PoshCode/d9442693-acf2-4df5-8552-91dec539a96f.ps1 | d9442693-acf2-4df5-8552-91dec539a96f.ps1 | <#
.SYNOPSIS
Writes out the the words for 99 Bottle of Beer on the wall.
.DESCRIPTION
Writes out the the words for 99 Bottle of Beer on the wall.
.PARAMETER BottlesOfBeerOnTheWall
Give the starting number of how many bottles of beer that are on the wall.
Valid range is 2 to 99.
.PARAMETER Voice
Use if y... |
PowerShellCorpus/PoshCode/Get-Entropy.ps1 | Get-Entropy.ps1 | function Get-Entropy
{
<#
.SYNOPSIS
Calculate the entropy of a byte array.
Author: Matthew Graeber (@mattifestation)
.PARAMETER ByteArray
Specifies the byte array containing the data from which entropy will be calculated.
.EXAMPLE
C:\\PS> $RandArray = New-Object Byte[](10000)
C... |
PowerShellCorpus/PoshCode/Shift Operators_2.ps1 | Shift Operators_2.ps1 | #requires -version 2.0
Add-Type @"
public class Shift {
public static int Right(int x, int count) { return x >> count; }
public static uint Right(uint x, int count) { return x >> count; }
public static long Right(long x, int count) { return x >> count; }
public static ulong Right(ulong x, int ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.