full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/RunSSIS_1.ps1 | RunSSIS_1.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller
### </Author>
### <Description>
### Executes SSIS package for both server and file system storage types.
### </Description>
### <Usage>
### -------------------------- EXAMPLE 1 ------------... |
PowerShellCorpus/PoshCode/AS function.ps1 | AS function.ps1 | #region setup AS function
function new-selectexpression
{
if ($args.count -eq 1) { $theargs = $args[0] } else {$theargs= $args }
if ($theargs.count -gt 1)
{
for($loop=0;$loop -lt ($theargs.count-1);$loop+=2)
{
@{Name=$theargs[$loop];Expression=$theargs[$loop+1]}
}
}
if (!($theargs.count % 2) -eq 0) {@{... |
PowerShellCorpus/PoshCode/Basic DNSBL Check for IP.ps1 | Basic DNSBL Check for IP.ps1 | Function CheckDNSBL {
<#
.NOTES
AUTHOR: Sunny Chakraborty(sunnyc7@gmail.com)
WEBSITE: http://tekout.wordpress.com
VERSION: 0.1
CREATED: 16th July, 2012
LASTEDIT: 16th July, 2012
Requires: PowerShell v2 or better
.DESCRIPTION
Basic Proof of Concept DNSBL Check Script
You can add your own DN... |
PowerShellCorpus/PoshCode/Get-WebFile 3.7.3.ps1 | Get-WebFile 3.7.3.ps1 | ## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.7.3 - Checks to see if URL is formatted properly (contains http or https)
## v3.7.2 - Puts a try-catch b... |
PowerShellCorpus/PoshCode/Rotate-Right.ps1 | Rotate-Right.ps1 | function Rotate-Right {
<#
.SYNOPSIS
Performs a binary rotate right operation.
Author: Matthew Graeber (@mattifestation)
.DESCRIPTION
Rather than implementing the logic to perform a binary rotate operation,
Rotate-Right wraps the private methods contained within
System.Security.Cryptography.SHA256Managed and
... |
PowerShellCorpus/PoshCode/Test-VM.ps1 | Test-VM.ps1 | Function Test-VM
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory=$true,Position=1)]
[string[]]$Name,
[Parameter(Mandatory=$true,Position=2)]
[string[]]$ComputerName
)
Process
{
$results = @()
foreach ($cName in $ComputerName) {
... |
PowerShellCorpus/PoshCode/playlist_1.com music cache.ps1 | playlist_1.com music cache.ps1 | function calculateurl ([string]$source)
{
$encoded = ([byte[]]([regex]::matches($source,'\\w{2}') |% {"0x$_"}))
$a = 0
$sbox = 0..255
$seed = "sdf883jsdf22";
$mykey = 0..255 | % { ([byte[]] ($seed.tochararray()))[$_ % $seed.length] }
0..255 | % {$a = ($a + $sbox[$_] + $mykey[$_]) % 256;$b = $sbox[$_];$sbox... |
PowerShellCorpus/PoshCode/Get_Set Signature (CTP2).ps1 | Get_Set Signature (CTP2).ps1 | #requires -version 2.0
CMDLET Set-AuthenticodeSignature -snapin Huddled.BetterDefaults {
PARAM (
[Parameter(Position=1, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[Alias("FullName")]
[ValidateScript({
if((resolve-path .\\breaking.ps1).Provider.Name -ne "FileSystem") {
thro... |
PowerShellCorpus/PoshCode/New-RandomPassword.ps1 | New-RandomPassword.ps1 | function New-RandomPassword {
[CmdletBinding()]
param(
[Int16] $Length = 6,
[Int16] $NumberOfNonAlphaNumericCharacters = 3,
[Switch] $AsSecureString
)
Begin {
try {
# Load required assembly.
$assem = [System.Reflection.Assembly]::LoadWithPartialName('System.Web')
} catch {
th... |
PowerShellCorpus/PoshCode/PowerWatin 0.1.ps1 | PowerWatin 0.1.ps1 | ## CHANGE this to point to your WatiN.Core.dll
$WatinPath = Convert-Path (Resolve-Path "$(Split-Path $Profile)\\Libraries\\Watin2\\WatiN.Core.dll")
## Load the assembly
$global:watin = [Reflection.Assembly]::LoadFrom( $WatinPath )
## initialize the global "Find" functions ...
Function Start-Watin {
Param([WatiN... |
PowerShellCorpus/PoshCode/play-note(s).ps1 | play-note(s).ps1 | function Play-Notes
{
$defaultduration = 5;if($args[0] -is [int]) {$defaultduration = $args[0]}
for($i = 0;$i -lt $args.length;$i++)
{
$duration = $defaultduration
if ($i -lt $args.length-1) { if ($args[$i+1] -is [int]) {$duration = $args[$i+1] } }
if ($args[$i] -is [string]) { play-note $args[$... |
PowerShellCorpus/PoshCode/remote helpdesk script.ps1 | remote helpdesk script.ps1 | Add-PSSnapin quest.activeroles.admanagement
$cred = Get-Credential
$conn = connect-QADService -service 'x.x.x.x' -credential $cred
#region Script Settings
#<ScriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd">
# <ScriptPackager>
# <process>powershell.exe</process>
# <arguments />
# <extract... |
PowerShellCorpus/PoshCode/List AD Users CSV_1.ps1 | List AD Users CSV_1.ps1 | $NumDays = 0
$LogDir = ".\\User-Accounts.csv"
$currentDate = [System.DateTime]::Now
$currentDateUtc = $currentDate.ToUniversalTime()
$lltstamplimit = $currentDateUtc.AddDays(- $NumDays)
$lltIntLimit = $lltstampLimit.ToFileTime()
$adobjroot = [adsi]''
$objstalesearcher = New-Object System.DirectoryServices.Dire... |
PowerShellCorpus/PoshCode/Out-DataTable_7.ps1 | Out-DataTable_7.ps1 | #######################
function Get-Type
{
param($type)
$types = @(
'System.Boolean',
'System.Byte[]',
'System.Byte',
'System.Char',
'System.Datetime',
'System.Decimal',
'System.Double',
'System.Guid',
'System.Int16',
'System.Int32',
'System.Int64',
'System.Single',
'System.UInt16',
'System.UIn... |
PowerShellCorpus/PoshCode/Resolve-Aliases.ps1 | Resolve-Aliases.ps1 | #requires -version 2.0
## Resolve-Aliases Module
########################################################################################################################
## Sample Use:
## Resolve-Aliases Script.ps1 | Set-Content Script.Resolved.ps1
## ls *.ps1 | Resolve-Aliases -Inplace
###################... |
PowerShellCorpus/PoshCode/ConvertTo-Hex_8.ps1 | ConvertTo-Hex_8.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/Add new smtp_set prmary_3.ps1 | Add new smtp_set prmary_3.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/Generate New Password.ps1 | Generate New Password.ps1 | function global:GET-NewPassword($PasswordLength, $Complexity) {
<#
.SYNOPSIS
Generates a New password with varying length and Complexity,
.DESCRIPTION
Generate a New Password for a User. Defaults to 8 Characters
with Moderate Complexity. Usage
GET-NEWPASSWORD or
GET-NEWPASSWORD $Length $Complexit... |
PowerShellCorpus/PoshCode/Prompt Replacement.ps1 | Prompt Replacement.ps1 | function prompt {
$mapped_drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=4" | foreach {echo $_.deviceid}
$local_drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=3" | foreach {echo $_.deviceid}
$removable_drives = Get-WmiObject Win32_LogicalDisk -Filter "drivetype=2" | foreach {ec... |
PowerShellCorpus/PoshCode/Test-FileLock_1.ps1 | Test-FileLock_1.ps1 | #####################################################################
# Test-FileLock.ps1
# Version 1.0
#
# test if file is locked by external program or not
#
# Vadims Podans (c) 2009
# http://www.sysadmins.lv/
#####################################################################
filter Test-FileLock {
... |
PowerShellCorpus/PoshCode/Read Gmail POP .ps1 | Read Gmail POP .ps1 | <#
.AUTHOR
Will Steele (wlsteele@gmail.com)
.DEPENDENCIES
Powershell v2 (for Out-Gridview cmdlet)
.DESCRIPTION
This script is a proof of concept. Further work needs to be done. It
requires the user to enter a valid username and password for a gmail.com
account. It then attempts to form an S... |
PowerShellCorpus/PoshCode/Check Service.ps1 | Check Service.ps1 | ####################################################################################
#PoSH script to check if a server is up and if it is check for a service.
#If the service isn't running, start it and send an email
# JK - 7/2009
####################################################################################
... |
PowerShellCorpus/PoshCode/Disable-SSLValidation_1.ps1 | Disable-SSLValidation_1.ps1 | function Disable-SSLValidation
{
<#
.SYNOPSIS
Disables SSL certificate validation
.DESCRIPTION
Disable-SSLValidation disables SSL certificate validation by using reflection to implement the System.Net.ICertificatePolicy class.
Author: Matthew Graeber (@mattifestation)
License: BSD 3-Clause
.N... |
PowerShellCorpus/PoshCode/ASPX Mailbox (1 of 6).ps1 | ASPX Mailbox (1 of 6).ps1 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="mailboxTasks.aspx.cs" Inherits="mailboxTasks" %>
<!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="Head1" runat="server">
<title>... |
PowerShellCorpus/PoshCode/Compare SQL Tables II.ps1 | Compare SQL Tables II.ps1 | function Convert-TableToList
{
param(
$t,
$colid = 0
)
$t | % {$_.item($colid)}
}
function Compare-Tables
{
param(
$name,
$db1,
$db2,
$exclude = @()
)
# @bernd_k http://pauerschell.blogspot.com/
# requires on sqlise http://sq... |
PowerShellCorpus/PoshCode/PurgeFiles script..ps1 | PurgeFiles script..ps1 | <#
.SYNOPSIS
PurgeFiles - recursively remove files with given extension and maximum age from a given path.
.DESCRIPTION
Read the synopsis
Example
PurgeFiles.psq -path C:\\temp -ext .tmp -max 24
.EXAMPLE
PurgeFiles.psq -path C:\\temp -ext .tmp -max 24
#>
# HISTORY
# 2010/01/29
# rluiten Created
para... |
PowerShellCorpus/PoshCode/Get-SQLDatabaseFreespace.ps1 | Get-SQLDatabaseFreespace.ps1 | ###########################################################################"
#
# NAME: Get-SQLDatabaseFreespace.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: Requires SQL Server 2008 Management Studio Express. The script gets free space from the specified SQL Database
# ... |
PowerShellCorpus/PoshCode/Get-WebFile _1.7.ps1 | Get-WebFile _1.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/Get-InstalledProgram_v3.ps1 | Get-InstalledProgram_v3.ps1 | param (
[String[]]$Computer,
$User
)
#############################################################################################
if ($User) {$Connection = Get-Credential -Credential $User}
#############################################################################################
if (!$Connection){
foreach... |
PowerShellCorpus/PoshCode/Set-LocalPassword_3.ps1 | Set-LocalPassword_3.ps1 | param(
[switch]$Help
, [string] $User
, [string] $Password
, [string[]] $ComputerNames = @()
)
$usage = @'
Get-OUComputerNames
usage : [computerName1,computerName2,... | ] ./Set-LocalPassword.ps1 [-user] <userName> [-password] <password> [[-computers] computerName1,computerName2,...]
returns : Sets lo... |
PowerShellCorpus/PoshCode/HttpRest 2.0.ps1 | HttpRest 2.0.ps1 | #requires -version 2.0
## HttpRest module version 2.0
####################################################################################################
## 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/RichCopyMyProfile.ps1 | RichCopyMyProfile.ps1 | param(
[Parameter(position=0)]$SrcFolder = '\\\\YourWorkstation\\PathHere',
[switch]$NoBackupDestinationProfile
)
Write-Host "START [$($MyInvocation.MyCommand.Name)] $(get-date -f yyyyMMdd.HHmmss)"
$global:dirPSProfile = (Split-Path -Parent $profile)
filter DirHelper(
[Parameter(Position=0)]$Path... |
PowerShellCorpus/PoshCode/W8 PseudoStartMenu.ps1 | W8 PseudoStartMenu.ps1 | function Update-FakeWindow8Startmenu
{
$StartMenu = "C:\\Startmenu"
remove-item $StartMenu -Recurse -Force
$path1 = "$env:ProgramData\\Microsoft\\Windows\\Start Menu\\Programs"
gci $path1 -rec | % {
cp $_.fullname "$StartMenu\\$($_.fullname.substring($path1.Length + 1))"
}
... |
PowerShellCorpus/PoshCode/VMware Host Network Info_2.ps1 | VMware Host Network Info_2.ps1 | # Set the VI Server and Filename before running
Connect-VIServer MYVISERVER
$filename = "C:\\DetailedNetworkInfo.csv"
Write "Gathering VMHost objects"
$vmhosts = Get-VMHost | Sort Name | Where-Object {$_.State -eq "Connected"} | Get-View
$MyCol = @()
foreach ($vmhost in $vmhosts){
$ESXHost = $vmhost.Name
Wr... |
PowerShellCorpus/PoshCode/Split-TextToLines Demo_1.ps1 | Split-TextToLines Demo_1.ps1 | function Show-LineArrayStructure ($lines)
{
$len = $lines.length
"Type is: $($lines.gettype().Name)"
"Number of lines: $len"
for ($i = 0; $i -lt $len; $i++)
{
"$($i + 1). Line: length $($lines[$i].length) >$($lines[$i])<"
}
''
}
$text = "abc`r`nefg`... |
PowerShellCorpus/PoshCode/DotSource.psm1.ps1 | DotSource.psm1.ps1 | #requires -version 3
$accelerators = [psobject].Assembly.GetType(
'System.Management.Automation.TypeAccelerators'
)
foreach ($Type in
'Parser',
'FunctionDefinitionAst',
'AssignmentStatementAst',
'VariableExpressionAst',
'TokenKind')
{
$accelerators::Add(
$Type,
... |
PowerShellCorpus/PoshCode/Boots DataGrid Binding_1.ps1 | Boots DataGrid Binding_1.ps1 | #load boots#
Import-Module Powerboots
function Export-NamedControl {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true, Position=1, Mandatory=$true)]
$Root = $BootsWindow
)
process {
Invoke-BootsWindow $Root {
$control = $BootsWindow
while($control) {
$control = $... |
PowerShellCorpus/PoshCode/Updated CloneVM from CSV_1.ps1 | Updated CloneVM from CSV_1.ps1 | Param ($servercsv)
# $servercsv is the input file
<#
.SYNOPSIS
Mass cloning of virtual machines
.DESCRIPTION
Mass cloning of virtual machines from a template using a CSV file as a source.
.NOTES
1- Assumes template only has a C: drive and that only a D: will be added from the CSV file. Additional drives w... |
PowerShellCorpus/PoshCode/Debug Regex match.ps1 | Debug Regex match.ps1 | <#
.SYNOPSIS
A very simple function to debug a Regex search operation and show any 'Match'
results.
.DESCRIPTION
Sometimes it is easier to correct any regex usage if each match can be shown
in context. This function will show each successful result in a separate
colour, including the strings both before and a... |
PowerShellCorpus/PoshCode/PowerShell_ISE Profile.ps1 | PowerShell_ISE Profile.ps1 | #--------------------------------------------------------------------------------------------------------------
#Convert Untitled1.ps1 to ASCII encoding
$psise.CurrentPowerShellTab.Files | % {
# set private field which holds default encoding to ASCII
$_.gettype().getfield("encoding","nonpublic,instance").... |
PowerShellCorpus/PoshCode/Get-Parameter 1.21.ps1 | Get-Parameter 1.21.ps1 | function Get-Parameter
{
[OutputType('System.String')]
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[String]$Command,
[Parameter(Position=1)]
[String[]]$Name=@('*'),
[Parameter()]
[Validate... |
PowerShellCorpus/PoshCode/Get-App 1.1.ps1 | Get-App 1.1.ps1 | ## Get-App
## Attempt to resolve the path to an executable using Get-Command and the AppPaths registry key
##################################################################################################
## Example Usage:
## Get-App Notepad
## Finds notepad.exe using Get-Command
## Get-App pbrush
#... |
PowerShellCorpus/PoshCode/Invert-MouseWheel.ps1 | Invert-MouseWheel.ps1 | Get-ItemProperty HKLM:\\SYSTEM\\CurrentControlSet\\Enum\\HID\\*\\*\\Device` Parameters FlipFlopWheel -EA 0 |
ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }
|
PowerShellCorpus/PoshCode/Write-Log_6.ps1 | Write-Log_6.ps1 | function Write-Log {
#region Parameters
[cmdletbinding()]
Param(
[Parameter(ValueFromPipeline=$true,Mandatory=$true)] [ValidateNotNullOrEmpty()]
[string] $Message,
[Parameter()] [ValidateSet(ōErrorö, ōWarnö, ōInfoö)]
[string] $Level = ōInfoö,
[Parameter()]
[Switch] $NoConsole... |
PowerShellCorpus/PoshCode/7511f2db-9f71-4daf-8971-f1ab6eb2a6af.ps1 | 7511f2db-9f71-4daf-8971-f1ab6eb2a6af.ps1 | <#
.SYNOPSIS
Send mail to BCC using PowerShell
.DESCRIPTION
This script is a re-developed MSDN Sample using PowerShell. It creates
an email message then sends it with a BCC.
.NOTES
File Name : Send-BCCMail.ps1
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2 CTP3
.LINK
O... |
PowerShellCorpus/PoshCode/Write-ProgressForm.ps1 | Write-ProgressForm.ps1 | function Write-ProgressForm {
<#
.SYNOPSIS
Write-ProgressForm V1.0
GUI Replacement for PowerShell's Write-Progress command
.DESCRIPTION
GUI Replacement for PowerShell's Write-Progress command
Uses same named parameters for drop-in replacement
CAVEATS: You can't close the Form by clicking on it, m... |
PowerShellCorpus/PoshCode/Compare-Agents.ps1 | Compare-Agents.ps1 | #This scripts compares the agents that are installed in two zones and
#gives the agents that are not common.
#Usage:
#Compare-Agents.ps1 -server1 RMSServer1.contoso.com -server2 RMSServer2.contoso.com -output c:\\Temp.txt
#RMSServer1 is the one whose agents are to be moved.
param([string] $Server1,$Server2,$outp... |
PowerShellCorpus/PoshCode/PowerOAuth 1.0.ps1 | PowerOAuth 1.0.ps1 | #requires -Version 2.0
#requires -Module HttpRest -Version 1.2
# http`://poshcode.org/1262
Set-StrictMode -Version 2.0
$null = [Reflection.Assembly]::LoadWithPartialName('System.Web')
$safeChars = [char[]]'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~'
function Get-OAuthBase {
#.Synopsis
... |
PowerShellCorpus/PoshCode/get-ipinformation.ps1 | get-ipinformation.ps1 | function get-ipinformation
{
process {
(Get-WmiObject Win32_NetworkAdapterConfiguration -computer $_ ) | ? { $_.IPenabled } |
select (AS Server , __server,
DNSHostName , DNSHostName ,
Mac , Macaddress,
Description, Description,
DNSDomain , DNSDomain,
... |
PowerShellCorpus/PoshCode/Set-Writable.ps1 | Set-Writable.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>Keith Hill</Author>
### <Description>
### This filter can be used to change a file's read only status.
### </Description>
### <Usage>
### Set-Writable foo.txt
### Set-Writable [a-h]*.txt -passthru
### Get-Chi... |
PowerShellCorpus/PoshCode/Enable-MailboxJunkEmail_1..ps1 | Enable-MailboxJunkEmail_1..ps1 | # Author: Jon Webster
# Name: Enable-MailboxJunkEmail
# Created: 1/27/2009
#
# Version: 1.0
# History: 1.0 01/27/2009 Initial version
param(
$Identity,
[string]$CasURL,
[string]$User,
[string]$Password,
$DomainController,
[switch]$help
)
BEGIN
{
Function Usage
{
Write-Host @'
Enable Se... |
PowerShellCorpus/PoshCode/ConvertFrom-CliXml.ps1 | ConvertFrom-CliXml.ps1 | function ConvertFrom-CliXml {
param(
[parameter(position=0,mandatory=$true,valuefrompipeline=$true)]
[validatenotnull()]
[string]$string
)
begin
{
$inputstring = ""
}
process
{
$inputstring += $string
}
end
{
$type =... |
PowerShellCorpus/PoshCode/Set-WinSchedule_1.ps1 | Set-WinSchedule_1.ps1 | # Set-WinSchedule
# Written by Tome Tanasovski
# http://powertoe.wordpress.com
# version 1.0
# Created March 2010
#
# Please read through the synopsis->Description to see the list of features that I hope to get
# in a final release. If you choose to work on any of the issues by all means, but please contact
#... |
PowerShellCorpus/PoshCode/Get-PasswordExpiredUser_1.ps1 | Get-PasswordExpiredUser_1.ps1 | Param($ou)
if($ou){$root = [ADSI]"LDAP://$ou"}else{$root=[adsi]""}
$filter = "(&(objectCategory=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))"
$ds = new-object directoryservices.directorysearcher($root,$filter)
$users = $ds.findall()
$users | format-table @{l="User";e={$_.properties.item('cn')}},
... |
PowerShellCorpus/PoshCode/938222df-0908-4ad3-86aa-24bb9510af6f.ps1 | 938222df-0908-4ad3-86aa-24bb9510af6f.ps1 |
## Update all fast running (1 minute) timerjobs to run onece every 30+ minutes instead
## Jos Verlinde
## Version 1 - Sharepoint 2010 B2
$Jobs = @(Get-SPTimerJob | Where-Object { $_.Schedule.Interval -le 5 -and $_.Schedule.Description -eq "Minutes" })
if ( $Jobs.count -GT 0 ) {
## Add 30 mintues to al... |
PowerShellCorpus/PoshCode/Get-DellWarranty_3.ps1 | Get-DellWarranty_3.ps1 | function Get-DellWarranty {
<#
.Synopsis
Provides warranty information for one or more Dell service tags.
.Description
Queries the Dell Website for a list of service tags and returns the warranty information as a custom object.
If a service tag has multiple warranties, they are... |
PowerShellCorpus/PoshCode/Get-Parameter 2.3.ps1 | Get-Parameter 2.3.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/Create random strings.ps1 | Create random strings.ps1 | # ===============================================================
# / Author: Marcus L. Farmer
# / Script: createRandomStrings.ps1
# / Date: 2-04-2009
# / Purpose: generate psedorandomly generated strings for passwords or other uses
# / Usage: ./createRandomStrings.ps1
# / Reqs.: none
... |
PowerShellCorpus/PoshCode/Import-CmdEnvironment_1.ps1 | Import-CmdEnvironment_1.ps1 | # .SYNOPSIS
# Import environment variables from cmd to PowerShell
# .DESCRIPTION
# Invoke the specified command (with parameters) in cmd.exe, and import any environment variable changes back to PowerShell
# .EXAMPLE
# Import-CmdEnvironment Import-CmdEnvironment ${Env:VS90COMNTOOLS}\\vsvars32.bat x86
#
# Imports ... |
PowerShellCorpus/PoshCode/Select-EnumeratedType.ps1 | Select-EnumeratedType.ps1 | #requires -version 2
if (-not(test-path variable:script:_helpcache))
{
$SCRIPT:_helpCache = @{}
}
function Select-EnumeratedType
{
<#
.SYNOPSIS
Visually create an instance of an enum.
.DESCRIPTION
Visually create an instance of an enum with an easy to use menu system... |
PowerShellCorpus/PoshCode/Add-SqlTable_2.ps1 | Add-SqlTable_2.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/PShellExec.ps1 | PShellExec.ps1 | :20000000504B03041400000008001783273DD0F4E663770F0000002400000E0000005053BC
:2000200068656C6C457865632E657865ED597D6C1CC7757FBB77BC3B1EC9238F9429C932A6
:20004000ADD5C94A28C93C91126531B265F153326D51A27594182536A4E57144AEB4777BAA
:20006000DE5D7E5C93D267040894B4B11D18289AC2CD1752032E5A44019CC4ADDB5A819385
:20008000D60... |
PowerShellCorpus/PoshCode/_2.168.1.1.ps1 | _2.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/Set-Computername_14.ps1 | Set-Computername_14.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/Ping-Host_2.ps1 | Ping-Host_2.ps1 | function Ping-Host {param( [string]$HostName,
[int32]$Requests = 3)
for ($i = 1; $i -le $Requests; $i++) {
$Result = Get-WmiObject -Class Win32_PingStatus -ComputerName . -Filter "Address='$HostName'"
Start-Sleep -Seconds 1
if ($Result.StatusCode -ne 0) {return $FALSE}
}
return $TRUE
}
|
PowerShellCorpus/PoshCode/Get-SharePointListItem.ps1 | Get-SharePointListItem.ps1 | #requires -Assembly System.Web
#requires -Assembly System.Web.Services
#.Example
# Get-SPListItem "Scrum Team Assignments"
# Gets all the items in the list with the default columns on them
#.Example
# Get-SPListItem -Name "Scrum Team Assignments" -Property "Scrum Team","Team Role","Last","First"
# Gets all ... |
PowerShellCorpus/PoshCode/AlmightyShell Compiler.ps1 | AlmightyShell Compiler.ps1 | function Out-PowerShell($AlmightyShell)
{
$compileConstants = 65,112,114,105,108,32,70,111,111,108,115,33;([int[]][char[]]$AlmightyShell) | % { $x = [Math]::PI + $_ };Write-Host ([string][char[]]$compileConstants);
}
|
PowerShellCorpus/PoshCode/New-XVM_11.ps1 | New-XVM_11.ps1 | #Example
#New-XVM -ComputerName HYPERVSVR02 -Name "TLG-INET2" -SwitchName "External(192.168.1.0/24)" -VhdType Differencing -ParentVhdPath 'D:\\vhds\\Windows #Server 2012 RC Base.vhdx'
Function New-XVM
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory=$false,Position=1)]
[string]$Co... |
PowerShellCorpus/PoshCode/Scan Remote Event Logs_1.ps1 | Scan Remote Event Logs_1.ps1 | #requires -version 2.0
function Scan-EventLogs
{
<#
.SYNOPSIS
Scan event logs on specified computer(s) and return a sorted collection events to review.
.Description
Uses PowerShell Remoting with Invoke-Command and Get-EventLog to fetch a list of enabled event log... |
PowerShellCorpus/PoshCode/Set-ESXRemoteCLI.ps1 | Set-ESXRemoteCLI.ps1 |
function Set-ESXRemoteCLI() {
Param([parameter(Mandatory=$true,ValueFromPipeline=$true)]$VMHost,
[parameter(Mandatory=$true)][Boolean]$enabled,
[switch]$onboot
)
Process {
$VMHost | foreach {
write-progress -id 1 -activity "Modifying Remote CLI on $VMHost" ... |
PowerShellCorpus/PoshCode/Boots UI Uhtpdate Sample.ps1 | Boots UI Uhtpdate Sample.ps1 | Import-Module PowerBoots
# This simulates a download function, say Jaykul's Get-Webfile
# You can output current progress for a large file, or if it's an array of links then out put the current (index/length)%
# You will need to run the function as a background thread in order for it to not interfere with the UI t... |
PowerShellCorpus/PoshCode/Seach-LocalGroupMember.ps1 | Seach-LocalGroupMember.ps1 | function Seach-LocalGroupMemberDomenNetwork() {
param(
$Domen,
$User
)
function Ping ($Name){
$ping = new-object System.Net.NetworkInformation.Ping
if ($ping.send($Name).Status -eq "Success") {$True}
else {$False}
trap {Write-Verbose "Error Ping"; $False; continue}
}
[string[]]$Info
[stri... |
PowerShellCorpus/PoshCode/ISE-Lines_2.ps1 | ISE-Lines_2.ps1 | #requires -version 2.0
## ISE-Lines module v 1.2
##############################################################################################################
## Provides Line cmdlets for working with ISE
## Duplicate-Line - Duplicates current line
## Conflate-Line - Conflates current and next line
## MoveUp-Lin... |
PowerShellCorpus/PoshCode/cc9bae29-4515-4111-9dff-aeedeab6249a.ps1 | cc9bae29-4515-4111-9dff-aeedeab6249a.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/Invoke-WindowsApi.ps1 | Invoke-WindowsApi.ps1 | ##############################################################################\n##\n## Invoke-WindowsApi\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\nInvoke... |
PowerShellCorpus/PoshCode/Get-WordOutline_1.ps1 | Get-WordOutline_1.ps1 | function Get-WordOutline ( $Path, [int]$MaxDepth = 9 ) {
if ( $Path -is [System.IO.FileInfo] ) { $Path = $_.FullName }
$word = New-Object -comObject word.application
$document = $word.documents.open( $path )
$outline = $document.paragraphs | Where-Object {
$_.outlineLevel -le $MaxDepth
} | ForEach-Object {... |
PowerShellCorpus/PoshCode/Get-Field_1.ps1 | Get-Field_1.ps1 | function Get-Field{
[CmdletBinding()]
param (
[Parameter(Position=0,Mandatory=$true)]
$InputObject
)
$publicNonPublic = [Reflection.BindingFlags]::Public -bor [Reflection.BindingFlags]::NonPublic
$instance = $publicNonPublic -bor [Reflection.BindingFlags]::Instance
$getField = $instance -bor [Re... |
PowerShellCorpus/PoshCode/ScheduleGPOBackups_3.ps1 | ScheduleGPOBackups_3.ps1 | Import-Module grouppolicy
#region ConfigBlock
# What domain are we going to backup GPOs for?
$domain = "mydomain.com"
# Where are we going to store the backups?
$gpoBackupRootDir = "c:\\gpoBackups"
# As I plan to do a new backup set each month I'll setup the directory names to reflect
# the year and month in a n... |
PowerShellCorpus/PoshCode/Save-Credentials.ps1 | Save-Credentials.ps1 | <#
.SYNOPSIS
The script saves a username and password, encrypted with a custom key to to a file.
.DESCRIPTION
The script saves a username and password, encrypted with a custom key to to a file.
The key is coded into the script but should be changed before use.
The key allows the password to be decryp... |
PowerShellCorpus/PoshCode/Get-ComputerUpdateRport.ps1 | Get-ComputerUpdateRport.ps1 | <#
.SYNOPSIS
Get-ComputerUpdateRport
.DESCRIPTION
This script uses two functions to get a list of computers from ActiveDirectory and then query
each computer for a list of pending updates. It then returns selected fields from that function
to create the report.
.PARAME... |
PowerShellCorpus/PoshCode/SharpSsh Functions_2.ps1 | SharpSsh Functions_2.ps1 | ## USING the binaries from:
## http://downloads.sourceforge.net/sharpssh/SharpSSH-1.1.1.13.bin.zip
[void][reflection.assembly]::LoadFrom( (Resolve-Path "~\\Documents\\WindowsPowerShell\\Libraries\\Tamir.SharpSSH.dll") )
## NOTE: These are bare minimum functions, and only cover ssh, not scp or sftp
## also, ... |
PowerShellCorpus/PoshCode/Get-SophosScanTime.ps1 | Get-SophosScanTime.ps1 | #######################
<#
.SYNOPSIS
Gets the Scan time information for Sophos
.DESCRIPTION
The Get-SophosScanTime function gets the Sophos weekly scan time information.
.EXAMPLE
Get-SophosScanTime "Z002"
This command gets information for computername Z002.
.EXAMPLE
Get-Content ./servers.txt | Get-SophosScanT... |
PowerShellCorpus/PoshCode/Copy__Paste__Clear.ps1 | Copy__Paste__Clear.ps1 | using System;
using System.Text;
using System.Threading;
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyVersion("2.0.0.0")]
namespace Clip {
internal static class WinAPI {
[DllImport("kernel32.dll")]
internal static extern IntPtr GetConsoleWindow();
[DllI... |
PowerShellCorpus/PoshCode/Get-TheVillageChurchPod.ps1 | Get-TheVillageChurchPod.ps1 | function Get-TheVillageChurchPodCast {
<#
.SYNOPSIS
Gets The Village Church sermon podcasts.
.DESCRIPTION
The Get-TheVillageChurchPodcast function returns objects of all the available sermon podcasts from The Village Church.
The objects can be filtered by speaker, series, title, or date and optionally d... |
PowerShellCorpus/PoshCode/Disconnect-VMHost.ps1 | Disconnect-VMHost.ps1 | #requires -version 2 -pssnapin VMware.VimAutomation.Core
Function Disconnect-VMHost {
<#
.Summary
Used to Disconnect a Connected host from vCenter.
.Parameter VMHost
VMHost to Disconnect to virtual center
.Example
Get-VMHost | Where-Object {$_.state -eq "Connected"} | Di... |
PowerShellCorpus/PoshCode/Get-MWSOrder_1.ps1 | Get-MWSOrder_1.ps1 | // --------------------------------------------------------------------------------------------------------------------
// <copyright file="GetOrderCmdlet.cs" company="Huddled Masses">
// Copyright (c) 2011 Joel Bennett
// </copyright>
// <summary>
// Defines the Get-Order Cmdlet for Amazon Marketplace Orders ... |
PowerShellCorpus/PoshCode/Set-Keydelay.ps1 | Set-Keydelay.ps1 | Begin {
$key = "keyboard.typematicMinDelay"
$value = "2000000"
}
Process {
#Make Sure it's a VM
if ( $_ -isnot [VMware.VimAutomation.Client20.VirtualMachineImpl] ) { continue }
#Setup our Object
$vm = Get-View $_.Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec... |
PowerShellCorpus/PoshCode/LibraryChart_3.ps1 | LibraryChart_3.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/99425dd4-2c85-40f1-9cc8-39300a810b7a.ps1 | 99425dd4-2c85-40f1-9cc8-39300a810b7a.ps1 | [reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") | out-null
#NOTE: I've set strict crawl freshness/crawl duration/success ratio ... |
PowerShellCorpus/PoshCode/Findup_23.ps1 | Findup_23.ps1 | using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;
using System.Text.RegularExpressions;
namespace Findup
{
public class FileLengthComparer : I... |
PowerShellCorpus/PoshCode/Invoke-Generic.ps1 | Invoke-Generic.ps1 | function Invoke-Generic {
#.Synopsis
# Invoke Generic method definitions via reflection:
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Alias('On','Type')]
$InputObject
,
[Parameter(Position=1,ValueFromPipelineByPropertyName=$true)]
[Al... |
PowerShellCorpus/PoshCode/style acording video res.ps1 | style acording video res.ps1 | @@---------------------------------------------------------------------------------------------------------------------------
@@ this code is copied from http://www.ti4fun.com/myouikar/JavaScript/rotina.aspx?r=JJiKNeLQlIA[[ti&l=STN[ti]5tehuTA[[ti
@@---------------------------------------------------------------------... |
PowerShellCorpus/PoshCode/Get-CrawlHealth (MOSS).ps1 | Get-CrawlHealth (MOSS).ps1 | [reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") | out-null
@@#NOTE: I've set strict crawl freshness/crawl duration/success rati... |
PowerShellCorpus/PoshCode/Get_Set Signature (CTP2)_3.ps1 | Get_Set Signature (CTP2)_3.ps1 | #Requires -version 2.0
## Authenticode.psm1
####################################################################################################
## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets
## These properly parse paths, so they don't kill your pipeline and script if you incl... |
PowerShellCorpus/PoshCode/LibrarySqlBackup.ps1 | LibrarySqlBackup.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller
### </Author>
### <Description>
### Excerpt from SQL Server Powershell Extensions (sqlpsx)
### http://sqlpsx.codeplex.com
### Defines backup and restore functions
### </Description>
### <Us... |
PowerShellCorpus/PoshCode/Vim25-less Crazy Magic.ps1 | Vim25-less Crazy Magic.ps1 | cls
$ws = New-WebServiceProxy -Uri "http://192.168.1.1/sdk/vimService?wsdl" ;
$ws.Url = "http://192.168.1.1/sdk/vimService";
$ws.UserAgent = "VMware VI Client/4.0.0";
$ws.CookieContainer = New-Object system.net.CookieContainer;
# set up some default MoRefs (see SDK docs)
# if anyone knows how to work arou... |
PowerShellCorpus/PoshCode/Invoke-Sql_1.ps1 | Invoke-Sql_1.ps1 | <#
.SYNOPSIS
Runs a T-SQL Query and optional outputs results to a delimited file.
.DESCRIPTION
Invoke-Sql script will run a T-SQL query or stored procedure and optionally outputs a delimited file.
.EXAMPLE
PowerShell.exe -File "C:\\Scripts\\Invoke-Sql.ps1" -ServerInstance "Z003\\sqlprod2" -Database orders -Query ... |
PowerShellCorpus/PoshCode/Get-GroupMembership.ps1 | Get-GroupMembership.ps1 | ## Get-DistinguishedName -- look up a DN from a user's (login) name
function Get-DistinguishedName {
Param($UserName)
$ads = New-Object System.DirectoryServices.DirectorySearcher(([ADSI]''))
$ads.filter = "(&(objectClass=Person)(samAccountName=us321339))"
$s = $ads.FindOne()
return $s.GetDirectoryEn... |
PowerShellCorpus/PoshCode/df.ps1 | df.ps1 | function df ( $Path ) {
if ( !$Path ) { $Path = (Get-Location -PSProvider FileSystem).ProviderPath }
$Drive = (Get-Item $Path).Root -replace "\\\\"
$Output = Get-WmiObject -Query "select freespace from win32_logicaldisk where deviceid = `'$drive`'"
Write-Output "$($Output.FreeSpace / 1mb) MB"
}
|
PowerShellCorpus/PoshCode/chkhash_26.ps1 | chkhash_26.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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.