full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Sweet Child O' Mine.ps1 | Sweet Child O' Mine.ps1 | #First Stanza
[System.Console]::Beep(587.3,200)
[System.Console]::Beep(1174.7,200)
[System.Console]::Beep(880,200)
[System.Console]::Beep(784,200)
[System.Console]::Beep(1568,200)
[System.Console]::Beep(880,200)
[System.Console]::Beep(1480,200)
[System.Console]::Beep(880,200)... |
PowerShellCorpus/PoshCode/Get MOSS User Profile.ps1 | Get MOSS User Profile.ps1 | function Get-UserProfile($accountName)
{
[reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server") | out-null
$upm =[Microsoft.Office.Server.UserProfiles.UserProfileManager](
[Microsoft.Office.Server.ServerContext]::D... |
PowerShellCorpus/PoshCode/DEMO_ Trap Ctrl+C.ps1 | DEMO_ Trap Ctrl+C.ps1 | function Trap-CtrlC {
## Stops Ctrl+C from exiting this function
[console]::TreatControlCAsInput = $true
## And you have to check every keystroke to see if it's a Ctrl+C
## As far as I can tell, for CtrlC the VirtualKeyCode will be 67 and
## The ControlKeyState will include either "LeftCtrlPressed"... |
PowerShellCorpus/PoshCode/Test-Port_5.ps1 | Test-Port_5.ps1 | Param([string]$srv,$port=135,$timeout=3000,[switch]$verbose)
# Test-Port.ps1
# Does a TCP connection on specified port (135 by default)
$ErrorActionPreference = "SilentlyContinue"
# Create TCP Client
$tcpclient = new-Object system.Net.Sockets.TcpClient
# Tell TCP Client to connect to machine on Port
... |
PowerShellCorpus/PoshCode/chkhash_31.ps1 | chkhash_31.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/Import-Delimited 2.4.ps1 | Import-Delimited 2.4.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/bb6a122a-f80d-4233-b795-beee3a70c3c0.ps1 | bb6a122a-f80d-4233-b795-beee3a70c3c0.ps1 | ####################################################################################################
## Script Name: N++CR FuncGuard Module
## Created On: 12/19/2009
## Author: Thell Fowler
## File: FuncGuard.psm1
## Usage:
## Version: 0.0.1
## Purpose: Pro... |
PowerShellCorpus/PoshCode/demo-attributes.ps1 | demo-attributes.ps1 | function demo-attributes
{
[System.Configuration.SettingsDescription({
@{something = 1;
this = 'that';
array = (1,2,3);
sub = @{ sub1 = 1 ; sub2 =2 }
}})]
[CmdletBinding(DefaultParameterSetName="noname")]
param (
[Parameter(Position=1,mandatory = $true)]
[string]$somethin... |
PowerShellCorpus/PoshCode/Get-WebFile 3.0.ps1 | Get-WebFile 3.0.ps1 | ## Get-WebFile.ps1 (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3 - rewritten completely using HttpWebRequest + HttpWebResponse to figure out the file name, if possibl... |
PowerShellCorpus/PoshCode/Xml Module 3.1.ps1 | Xml Module 3.1.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.
# IMPO... |
PowerShellCorpus/PoshCode/Copy-Item extended.ps1 | Copy-Item extended.ps1 | function Copy-ToCreateFolder
{
param(
[string]$src,
[string]$dest,
$exclude,
[switch]$Recurse
)
# The promlem with Copy-Item -Rec -Exclude is that -exclude effects only top-level files
# Copy-Item $src $dest -Exclude $exclude -EA silentlycontinue -... |
PowerShellCorpus/PoshCode/Get-EasterEastern.ps1 | Get-EasterEastern.ps1 | function Get-EasterEastern {
Param(
[Parameter(Mandatory=$true)]
[int] $Year
)
$a = $Year % 4
$b = $Year % 7
$c = $Year % 19
$d = ((19 * $c) + 15) % 30
$e1 = -$d #here because powershell is picking up - (subtraction operator) as incorrect toekn
$e = ((2 * $a) + (4 * $b) + ... |
PowerShellCorpus/PoshCode/PowerShellServer Cmdlet _2.ps1 | PowerShellServer Cmdlet _2.ps1 | \n#Global Hashtable to Control all Powershell Server Runspace\nSet-Variable -name '__PSRUNSPACES__' -scope 'global' -value @{} -force\n\nfunction global:New-PowerShellServerRunspace\n{\n param(\n $Credential,\n $ErrorAction='Stop',\n [switch]$Force,\n $Password,\n $Port=22,\n $Server='127.0.0.1',\n $SSHAccept,\n... |
PowerShellCorpus/PoshCode/Remove-SMVISnapshots.ps1 | Remove-SMVISnapshots.ps1 | <#
.Synopsis
Cleanup after SMVI
.PARAMETER Max
Maximum number of concurrent snapshot delete tasks. Default: 5
.PARAMETER Recurse
Recursively process snapshots untill they are all gone.
.Example
.\\Remove-SMVISnapshots.ps1 -Max 10
removes the 10 newest smvi leftovers, and returns the ... |
PowerShellCorpus/PoshCode/Logoff all users.ps1 | Logoff all users.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/New-WebServiceProxy_1.ps1 | New-WebServiceProxy_1.ps1 | #
# New-WebServiceProxy.ps1 (v3.0 Sep 23, 2009)
#
# Oisin Grehan <oising@gmail.com> (x0n)
#
# Usage:
# $proxy = .\\New-WebServiceProxy.ps1 [-Url] http://site/service.asmx [-Anonymous] [[-SoapProtocol] <Soap | Soap12>] [-Namespace <namespace>]
#
# to see available webmethods:
# $proxy | gm
#
# $url = "h... |
PowerShellCorpus/PoshCode/Execute-SQLCommand_1.ps1 | Execute-SQLCommand_1.ps1 | function Execute-SQLCommand {param( [string]$Server, #the host name of the SQL server
[string]$Database, #the name of the database
[System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlCo... |
PowerShellCorpus/PoshCode/VM Performance Report_3.ps1 | VM Performance Report_3.ps1 | <#
.SYNOPSIS
The script creates an HTML report for given vSphere VM's, that contains VM performance data over a given period. The script then emails the report to a given address.
.DESCRIPTION
The script requires an input file, supplied as an argument to the script. The first line of this file contains an e... |
PowerShellCorpus/PoshCode/Set-ConsoleProperties.ps.ps1 | Set-ConsoleProperties.ps.ps1 | ## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n\nSet-StrictMode -Version Latest\n\nPush-Location\nSet-Location HKCU:\\Console\nNew-Item '.\\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe'\nSet-Location '.\\%SystemRoot%_system32_WindowsPowerShell_v1.0_powe... |
PowerShellCorpus/PoshCode/Hex2Dec_5.ps1 | Hex2Dec_5.ps1 | <!DOCTYPE html>
<html>
<head>
<title>He2Dec</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript">
var num = {
hex2dec : function(n) {
return Number(n) ? Number(n) : 'Wrong data type';
},
... |
PowerShellCorpus/PoshCode/ConvertTo-Hex_4.ps1 | ConvertTo-Hex_4.ps1 | # Ported from C# technique found here: http://forums.asp.net/p/1298956/2529558.aspx
param ( [string]$SidString )
# Create SID .NET object using SID string provided
$sid = New-Object system.Security.Principal.SecurityIdentifier $sidstring
# Create a byte array of the proper length
$sidBytes = New-Object byte[] ... |
PowerShellCorpus/PoshCode/Get-WebFile 3.7.2.ps1 | Get-WebFile 3.7.2.ps1 | ## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.7.2 - Puts a try-catch block around $writer = new-object System.IO.FileStream and returns/breaks to
## ... |
PowerShellCorpus/PoshCode/Check latest BIOS Rev_1.ps1 | Check latest BIOS Rev_1.ps1 | $BiosRev = Get-WmiObject -Class Win32_BIOS -ComputerName $ComputerName -Credential $Credentials
# Shortened URL for the Dell Support page, fileid=441102, appears to be the identifier for BIOS downloads
# I tested this on a few different models of Dell workstations.
$DellBIOSPage = "http://support.dell.com/suppor... |
PowerShellCorpus/PoshCode/Get-MSCSRestartAction.ps1 | Get-MSCSRestartAction.ps1 | param($cluster)
gwmi -ComputerName $cluster -Namespace "root\\mscluster" -Class MSCluster_Resource | Select @{n='Cluster';e={$cluster}},Name, RestartAction
|
PowerShellCorpus/PoshCode/Sync-Time_2.ps1 | Sync-Time_2.ps1 | function sync-time(
[string] $server = "clock.psu.edu",
[int] $port = 37)
{
$servertime = get-time -server $server -port $port -set
#leave off -set to just check the remote time
write-host "Server time:" $servertime
write-host "Local time :" $(date)
}
|
PowerShellCorpus/PoshCode/Get-WebSite_6.ps1 | Get-WebSite_6.ps1 | function Get-WebSite {
<#
.SYNOPSIS
Retrieves information about a website.
.DESCRIPTION
Retrieves information about a website.
.PARAMETER Url
URL of the website to test access to.
.PARAMETER UseDefaultCredentials
Use the currently authenticated user's credentials
.PARAMETER Proxy
Us... |
PowerShellCorpus/PoshCode/Get-FileEncoding_2.ps1 | Get-FileEncoding_2.ps1 | ##############################################################################\n##\n## Get-FileEncoding\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\nGets th... |
PowerShellCorpus/PoshCode/Set-IPAddress_8.ps1 | Set-IPAddress_8.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/Get-GrowthRate_3.ps1 | Get-GrowthRate_3.ps1 | function Get-GrowthRate {
param( $Start, $End, $Period )
$rate = [math]::Abs( [math]::Pow( ( $End / $Start ),( 1 / ( $Period - 1 ) ) ) - 1 )
"{0:P}" -f $rate
}
|
PowerShellCorpus/PoshCode/PowerShell Talk Mass VMs.ps1 | PowerShell Talk Mass VMs.ps1 | #The PowerShell Talk
#Virtualization Congress 2009
#
#Provision from CSV (csv-provision.ps1)
#Grab from the cli the path to the csv file
Param ( $path_to_csv )
#Get credentials & Connect
Get-Credential | connect-viserver -server "Your vCenter Here"
#Import the CSV, and build our VMs
$csv = Import-Csv -Pa... |
PowerShellCorpus/PoshCode/Convert-BounceToX500.ps1 | Convert-BounceToX500.ps1 | # $Id: Convert-BounceToX500.ps1 608 2010-10-31 02:12:44Z jon $
# $Revision: 608 $
#.Synopsis
# Convert Bounce to X500
#.Description
# Convert URL Encoded address in a Bounce message to an X500 address
# that can be added as an alias to the mail-enabled object
#.Parameter bounceAddress
# URL Encoded bounce... |
PowerShellCorpus/PoshCode/Add-ADPhoto.ps1 | Add-ADPhoto.ps1 | #Add-ADPhoto Powershell v1 compatibile script for updating
#user thumbnailphoto attribute. Resizes input photo to recommended
#dimensions and size. Only updates for the currently logged in user.
#This is a script for user self service.
#Author: Nathan Linley
#Site: http://myitpath.blogspot.com
$infile = $... |
PowerShellCorpus/PoshCode/Wacth TechED Sessions.ps1 | Wacth TechED Sessions.ps1 | ipmo WPK
Function Get-TechEDSession {
$url = "https://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/RSS/"
$wc = New-Object net.webclient
#$wc.Proxy.Credentials = Get-Credential
$feed = ([xml]($wc.downloadstring($url))).rss.channel.item
$feed | ForEach {
... |
PowerShellCorpus/PoshCode/CIM SMI-S Query Library_1.ps1 | CIM SMI-S Query Library_1.ps1 | function Invoke-CIM_EnumerateInstances {
<#
.SYNOPSIS
Enumerate Instances of a class on a CIMOM via CIM-XML interface
.DESCRIPTION
Primary use case of this function is to gather inventory and performance information from IT
infrastructure assets. The inventory information feeds into capacity plannin... |
PowerShellCorpus/PoshCode/Get default AppPath.ps1 | Get default AppPath.ps1 | Function Get-ApplicationPath {
Param ([string[]]$extension)
Write-Verbose "Saving current location"
Push-Location
$extension | % {
try {
Set-Location "HKLM:\\Software\\Classes\\$($_)" -ErrorAction Stop
$default = (Get-ItemProperty -Path $pwd.Path -Name '(Defa... |
PowerShellCorpus/PoshCode/WPK_TunnelGradient.ps1 | WPK_TunnelGradient.ps1 | [CmdletBinding()]
param (
[string]$InsideColor = 'White',
[string]$OutsideColor = 'Transparent',
[int]$BorderThickness = 5
)
Add-Type -AssemblyName PresentationCore
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName WindowsBase
# script requires STA... let us check it.
if ([Th... |
PowerShellCorpus/PoshCode/Get-ChildItemColor.ps1 | Get-ChildItemColor.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
See Also... |
PowerShellCorpus/PoshCode/Autoload (beta 2).ps1 | Autoload (beta 2).ps1 | #Requires -Version 2.0
## Automatically load functions from scripts on-demand, instead of having to dot-source them ahead of time, or reparse them from the script every time.
## To use:
## 1) Create a function. To be 100% compatible, it should specify pipeline arguments
## For example:
<#
function Skip-Object {... |
PowerShellCorpus/PoshCode/Set Resource Limits.ps1 | Set Resource Limits.ps1 | Param([Parameter(Mandatory=$true)] [string]$VMGuest)
$vm = get-vm $VMGuest
$cpuCap = $vm.NumCPU*1000
$cpuRes = $cpuCap/2
$memCap = $vm.MemoryMB
$memRes = $memCap/4
$spec = new-object VMware.Vim.VirtualMachineConfigSpec;
$spec.memoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo;
$spec.memoryAll... |
PowerShellCorpus/PoshCode/SyntaxHighlighter Brush_1.ps1 | SyntaxHighlighter Brush_1.ps1 | //
/**
* PowerShell 2.0 Brush for highlighter 2.0
*
* SyntaxHighlighter http://alexgorbatchev.com/wiki/SyntaxHighlighter
*
* @version
* 2.1.0 (April 07 2009)
*
* @copyright
* Copyright (C) 2008-2009 Joel Bennett http://HuddledMasses.org/
*
* @license
* This file is for SyntaxHighlighter.
... |
PowerShellCorpus/PoshCode/Add Voice to Powershell.ps1 | Add Voice to Powershell.ps1 | ###
# Description: Add Voice to Powershell
# Version: 1.1 (11 Nov 2008)
# Mike Hays / www.mike-hays.net / blog.mike-hays.net
# Virtualization, Powershell, and more...
###
# This is the actual speaking part. I cheat by adding spaces
# (This makes the word sound right).
$spokenText = "Super ca li fragilistic e... |
PowerShellCorpus/PoshCode/Hack ESXi_3.ps1 | Hack ESXi_3.ps1 | $screen = " You see here a virtual switch. ------------ ------
#...........| |....|
--------------- ###------------ |...(|
|..%...........|########## ###-@...|
... |
PowerShellCorpus/PoshCode/The PowerShell Talk Xen2.ps1 | The PowerShell Talk Xen2.ps1 | #The PowerShell Talk
#Demo 2 - VM Easy Bake Oven
#XenServer
#Connect to XenServer
Get-Credential | connect-Xenserver -Url http://XenServer_URL/sdk
#Create the new VM
Create-XenServer:VM -NameLabel "Dave" -VCPUsAtStartup 1 -MemoryDynamicMax 536870912 -MemoryStaticMax 536870912 -MemoryDynamicMin 536870912 -Memo... |
PowerShellCorpus/PoshCode/Farm Backup.ps1 | Farm Backup.ps1 | ##################################
#This errors out in ISE, so use cmd window.
#The script below fixes the error just below.
#Cannot access the local farm. Verify that the local farm is
#properly configured, currently available, and that you have
#the appropriate permissions to access the database before
#tryi... |
PowerShellCorpus/PoshCode/Get-Dependency.ps1 | Get-Dependency.ps1 | $BuiltInAliases = @{}
$BuiltInCmdlets = @{}
$BuiltInFunctions = @{}
$BuiltInVariables = @{}
##############################################################################
#.SYNOPSIS
# Gets a list of tokenized strings from the specified PowerShell code sample
# which can be used for dependency analysis or o... |
PowerShellCorpus/PoshCode/FTP upload_6.ps1 | FTP upload_6.ps1 | @charset "utf-8";
/*
Credit:http://www.templatemo.com
*/
body {
margin: 0px;
padding: 0px;
color: #c2bead;
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
line-height: 1.5em;
background-color: #2f2e28;
background-image: url(images/templatemo_body.jpg);
background-repeat: repeat-y;
bac... |
PowerShellCorpus/PoshCode/Shift Operators(Correct)_1.ps1 | Shift Operators(Correct)_1.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 ... |
PowerShellCorpus/PoshCode/Migrate-ADMTUser.ps1 | Migrate-ADMTUser.ps1 | ###########################################################################"
#
# NAME: Migrate-ADMTUser.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: A function to migrate a single user in the Active Directory Migration Tool, based on the sample script Invoke-ADMTUserMigration.p... |
PowerShellCorpus/PoshCode/Get-HtmlHelp_2.ps1 | Get-HtmlHelp_2.ps1 | Hello,
I may have contacted you in the past, but wanted to reach out again to inquire about the possibility of advertising on your blog in the form of sponsored guest posts.
Either I can have content written or you can write content that is relevant to your audience and helps to promote our client's service. We... |
PowerShellCorpus/PoshCode/Add -__ Get-Help -Full.ps1 | Add -__ Get-Help -Full.ps1 | $executionContext.SessionState.InvokeCommand.PostCommandLookupAction = {
param($CommandName, $CommandLookupEventArgs)
# Only for interactive commands (and that doesn't include "prompt")
# I should exclude out-default so we don't handle it on every pipeline, but ...
if($CommandLookupEventArgs.Comma... |
PowerShellCorpus/PoshCode/Convert-FspToUsername.ps1 | Convert-FspToUsername.ps1 | Function Convert-FspToUsername
{
<#
.SYNOPSIS
Convert a FSP to a sAMAccountName
.DESCRIPTION
This function converts FSP's to sAMAccountName's.
.PARAMETER UserSID
This is the SID of the FSP in the form of S-1-5-20. These can be found
in... |
PowerShellCorpus/PoshCode/HttpRest 1.0.2.ps1 | HttpRest 1.0.2.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/TabExpansion for V2CTP_1.ps1 | TabExpansion for V2CTP_1.ps1 | ## Tab-Completion
#################
## For V2CTP3.
## This won't work on V1 and V2CTP and V2CTP2.
## 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... |
PowerShellCorpus/PoshCode/Get-MountPointData.ps1 | Get-MountPointData.ps1 | # Convert from one device ID format to another.
function Get-DeviceIDFromMP {
param([Parameter(Mandatory=$true)][string] $VolumeString,
[Parameter(Mandatory=$true)][string] $Directory)
if ($VolumeString -imatch '^\\s*Win32_Volume\\.DeviceID="([^"]+)"\\s*$') {
# Return it in th... |
PowerShellCorpus/PoshCode/Create-Printers_3.ps1 | Create-Printers_3.ps1 | ###########################################################################"
#
# NAME: Create-Printers.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
# BLOG: http://blog.powershell.no
#
# COMMENT: Simple script to bulk-create printers on a print-server. Printers are imported from a csv-file.... |
PowerShellCorpus/PoshCode/Updated CloneVM from CSV.ps1 | Updated CloneVM from CSV.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... |
PowerShellCorpus/PoshCode/h20 -Hashtables 2 object_5.ps1 | h20 -Hashtables 2 object_5.ps1 | #hashtable to object function.
#used to be able to make custom objects with math inside the pipeline
#e.g. 1..10 | h20 { @{karl = $_;dude = $_+1} }
#gps | h20 { @{name = $_.processname; mem = $_.workingset / 1MB} }
function h20([scriptblock]$sb )
{
begin {}
process{ if ($sb -ne $null)
{
... |
PowerShellCorpus/PoshCode/Start-RDP_1.ps1 | Start-RDP_1.ps1 | ########################################################################################################################
# NAME
# Start-RDP
#
# SYNOPSIS
# Opens a remote desktop connection to another computer.
#
# SYNTAX
# Start-RDP [[-Server] <string>] [[-Width] <int>] [[-Height] <int>]
# Star... |
PowerShellCorpus/PoshCode/Set-TopMost.ps1 | Set-TopMost.ps1 | #Requires -Version 2.0
$signature = @"
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
public static IntPtr FindWindow(string windowName){
return FindWindow(null,windowName);
}
[DllImport("user32.dll")]
public static extern bool Se... |
PowerShellCorpus/PoshCode/Set-DNSServersToOpenDNS.ps1 | Set-DNSServersToOpenDNS.ps1 | Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'" | ForEach-Object {
$_.SetDNSServerSearchOrder(@("208.67.222.222","208.67.220.220"));
}
|
PowerShellCorpus/PoshCode/Update-GAC.ps1 | Update-GAC.ps1 | # author: jeffrey snover
# url: http://blogs.msdn.com/powershell/archive/2008/09/02/speeding-up-powershell-startup-updating-update-gac-ps1.aspx
Set-Alias ngen (Join-Path ([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()) ngen.exe)
[AppDomain]::CurrentDomain.GetAssemblies() |
sort {Spli... |
PowerShellCorpus/PoshCode/Demo-v3-Gui.ps1 | Demo-v3-Gui.ps1 | #requires -version 3
[Windows.Window]@{
OpacityMask = [Windows.Media.DrawingBrush]@{
Drawing = [Windows.Media.GeometryDrawing]@{
Brush = 'Black'
Geometry = [Windows.Media.EllipseGeometry]@{
radiusX = 123
radiusY = 321
}
}... |
PowerShellCorpus/PoshCode/Add Voice to Powershell_2.ps1 | Add Voice to Powershell_2.ps1 | ###
# Description: Add Voice to Powershell
# Version: 1.1 (11 Nov 2008)
# Mike Hays / www.mike-hays.net / blog.mike-hays.net
# Virtualization, Powershell, and more...
###
# This is the actual speaking part. I cheat by adding spaces
# (This makes the word sound right).
$spokenText = "Super ca li fragilistic e... |
PowerShellCorpus/PoshCode/Execute-SQLCommand_2.ps1 | Execute-SQLCommand_2.ps1 | function Execute-SQLCommand {param( [string]$Server, #the host name of the SQL server
[string]$Database, #the name of the database
[System.Data.SqlClient.SqlCommand]$Command) #the command to execute (name of stored procedure)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlCo... |
PowerShellCorpus/PoshCode/Highlight-Syntax 1.0.ps1 | Highlight-Syntax 1.0.ps1 | # Highlight-Syntax.ps1
# version 1.0
# by Jeff Hillman
#
# this script uses regular expressions to highlight PowerShell
# syntax with HTML.
param( [string] $code, [switch] $LineNumbers )
if ( Test-Path $code -ErrorAction SilentlyContinue )
{
$code = Get-Content $code | Out-String
}
$backgroundColor... |
PowerShellCorpus/PoshCode/Build-TFSProjects_2.ps1 | Build-TFSProjects_2.ps1 | #-------------------------------------------------------------------------
# Script that will:
# 1. Create a workspace. Workspacce Name: _Root
# 2. Get the latest code from repository
#-------------------------------------------------------------------------
Param(
[switch]
$CSRWEB,
[switch]... |
PowerShellCorpus/PoshCode/validate an IP address_3.ps1 | validate an IP address_3.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/Repair-ScriptQuotes.ps1 | Repair-ScriptQuotes.ps1 | function Repair-ScriptQuotes {
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string]$path
)
if ( !( Test-Path $path ) ) {
Write-Warning "'$path' does not exist."
Continue
}
(( Get-Content $path) |
ForEach-Object {
... |
PowerShellCorpus/PoshCode/Powershell Only Outlook.ps1 | Powershell Only Outlook.ps1 | #connect to outlook
$GetOutlook = New-Object -com "Outlook.Application";
$olName = $GetOutlook.GetNamespace("MAPI")
$olxEmailFolder = $olName.GetDefaultFolder(‘olFolderInbox’)
$olxEmailFolder.Name
$olxEmailItem = $olxemailFolder.items
#show unread emails in inbox
$olxEmailItem | ?{$_.Unread -eq $True} | select ... |
PowerShellCorpus/PoshCode/New-VMHostShellAccount.ps1 | New-VMHostShellAccount.ps1 | # original by c_shanklin @ http://communities.vmware.com/message/1013362#1013362
function New-VMHostShellAccount {
param (
$Name,
$Password = $null,
$Description = $null,
$PosixId = $null
)
$SvcInstance = Get-View serviceinstance
$AcctMgr = Get-View $SvcInstance.Content.AccountManager
$AcctSpec... |
PowerShellCorpus/PoshCode/Chassis Type.ps1 | Chassis Type.ps1 | $SystemEnclosure = Get-WMIObject -Class Win32_SystemEnclosure; $Type = $SystemEnclosure.ChassisTypes; CLS ; Write-Host -BackgroundColor White -ForegroundColor Blue "Chassis Type:"
if ($Type -eq 1)
{Write-Host "$Type - Other"}
elseif ($Type -eq 2)
{Write-Host "$Type - Virtual Machine"}
elseif ($Type -eq 3)
... |
PowerShellCorpus/PoshCode/Invoke-LongRunningOperat.ps1 | Invoke-LongRunningOperat.ps1 | ##############################################################################\n##\n## Invoke-LongRunningOperation\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/Script permissions.ps1 | Script permissions.ps1 | <#
.SYNOPSIS
Applies permissions and roles to vSphere vApps
.DESCRIPTION
Applies permissions and roles to vSphere vApps
-VIServer (Optional, defaults to Development) {FQDN of VCentre Server}
-AppName (Required) {VApp Label}
-ADGroup (Optional) {Domain\\Group_Object}
-Role (Optional) {vSphere Role, ReadO... |
PowerShellCorpus/PoshCode/Invoke-Standby.ps1 | Invoke-Standby.ps1 | #Autor: Mateusz Świetlicki
#Site: mateusz.swietlicki.net
#Create: 2010-10-04
function Invoke-Shutdown
{
&"$env:SystemRoot\\System32\\shutdown.exe" -s
}
function Invoke-Reboot
{
&"$env:SystemRoot\\System32\\shutdown.exe" -r
}
function Invoke-Logoff
{
&"$env:SystemRoot\\System32\\shutd... |
PowerShellCorpus/PoshCode/New-WebServiceProxy_2.ps1 | New-WebServiceProxy_2.ps1 | #
# New-WebServiceProxy.ps1 (v3.0 Sep 23, 2009)
#
# Oisin Grehan <oising@gmail.com> (x0n)
#
# Usage:
# $proxy = .\\New-WebServiceProxy.ps1 [-Url] http://site/service.asmx [-Anonymous] [[-SoapProtocol] <Soap | Soap12>] [-Namespace <namespace>]
#
# to see available webmethods:
# $proxy | gm
#
# $url = "h... |
PowerShellCorpus/PoshCode/TheGameOfLife_1.ps1 | TheGameOfLife_1.ps1 | #TheGameOfLife.ps1
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$SCRIPT:hostProperties = @{};
$SCRIPT:hostState = $null;
$SCRIPT:BoardWidth = 50;
$SCRIPT:BoardHeight = 50;
Function Initialize-Host
{
Param(
[Parameter(Mandatory=$false)]
$wndTitle = "Game of Life... |
PowerShellCorpus/PoshCode/vProfiles_1.ps1 | vProfiles_1.ps1 | #
# vProfiles V1
# By Alan Renouf
# http://virtu-al.net
#
#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.3.0
# Generated On: 27/06/2009 9:17 PM
# Generated... |
PowerShellCorpus/PoshCode/ISE-Comments.ps1 | ISE-Comments.ps1 | #requires -version 2.0
## ISE-Comments module v 1.0
## DEVELOPED FOR CTP3
## See comments for each function for changes ...
##############################################################################################################
## Provides Comment cmdlets for working with ISE
## ConvertTo-BlockComment - C... |
PowerShellCorpus/PoshCode/Highlight-Syntax _1.0.ps1 | Highlight-Syntax _1.0.ps1 | # Highlight-Syntax.ps1
# version 1.0
# by Jeff Hillman
#
# this script uses regular expressions to highlight PowerShell
# syntax with HTML.
param( [string] $code, [switch] $LineNumbers )
if ( Test-Path $code -ErrorAction SilentlyContinue )
{
$code = Get-Content $code | Out-String
}
$backgroundColor... |
PowerShellCorpus/PoshCode/PowerShell Template_5.ps1 | PowerShell Template_5.ps1 | Function new-script
{
$strName = $env:username
$date = get-date -format d
$name = Read-Host "Filename"
$email = Read-Host "eMail Address"
$file = New-Item -type file "c:\\Scripts\\$name.ps1" -force
add-content $file "#=========================================================================="
add-content $file ... |
PowerShellCorpus/PoshCode/style acording video res_1.ps1 | style acording video res_1.ps1 | ---------------------------------------------------------------------------------------------------------------------------
this code is copied from http://www.ti4fun.com/myouikar/JavaScript/rotina.aspx?r=JJiKNeLQlIA[[ti&l=STN[ti]5tehuTA[[ti
---------------------------------------------------------------------------... |
PowerShellCorpus/PoshCode/Convert-ToCHexString_3.ps1 | Convert-ToCHexString_3.ps1 | function Convert-ToCHexString {
param([String] $input
$ans = ''
[System.Text.Encoding]::ASCII.GetBytes($str) | % { $ans += "0x{0:X2}, " -f $_ }
return $ans.Trim(',',' ')
}
|
PowerShellCorpus/PoshCode/ESX Lun Latencies_1.ps1 | ESX Lun Latencies_1.ps1 | function Get-VMHostLunLatency {
param([parameter(Mandatory=$true, ValueFromPipeline=$true)] $VMHost)
process {
$luns = Get-ScsiLun -VmHost $VMHost
$DiskStats = $VMHost |
Get-Stat -stat disk.totalreadlatency.average,disk.totalwritelatency.average -maxsamples 1 -realtime
foreach ($lun in $l... |
PowerShellCorpus/PoshCode/Set-IPAddress_4.ps1 | Set-IPAddress_4.ps1 | # ahhh ... much better. Don't ask for prompts. It's not scriptable if you do.
function Set-IPAddress {
param( [string]$networkinterface,
[string]$ip,
[string]$mask,
[string]$gateway,
[string]$dns1,
[string]$dns2,
[string]$registerDns=$true
)
$dns = $dns1
if($dns2){$dns ="$dns1","... |
PowerShellCorpus/PoshCode/Get-FtpList.ps1 | Get-FtpList.ps1 |
function Get-FtpList {
#.Synopsis
# Read a list of files (and directories) from FTP
#.Description
# An initial implementation of a string-parsing lister for FTP which converts lists to objects (in the one format that I've seen -- there are other formats)
#
# This implementation will use whatever proxy is set... |
PowerShellCorpus/PoshCode/gpupdate on remote pc's.ps1 | gpupdate on remote pc's.ps1 | ###############################################################################
#
# Get all servers from a OU and run GPUpdate /force on this machines.
#
# Version 1.0
#
# (C) 2009 - Arne Fokkema
# www.ict-freak.nl
#
# Install the Quest AD cmdlets first!!
#
###############################################... |
PowerShellCorpus/PoshCode/Dell Order Status_2.ps1 | Dell Order Status_2.ps1 | # Version: 0.1
# Author: Stefan Stranger
# Description: Retrieve Dell Order Status
# Start Page Order Status USA: https://support.dell.com/support/order/status.aspx?c=us&cs=19&l=en&s=dhs&~ck=pn
# Start Page Order Status EMEA(nl): http://support.euro.dell.com/support/index.aspx?c=nl&l=nl&s=gen&~ck=bt
# Example Dell... |
PowerShellCorpus/PoshCode/Get-Parameter_13.ps1 | Get-Parameter_13.ps1 | #Requires -version 2.0
##This is just script-file nesting stuff, so that you can call the SCRIPT, and after it defines the global function, it will call it.
param (
[Parameter(Position=1,ValueFromPipelineByPropertyName=$true,Mandatory=$true)]
$Name
,
[Parameter(Position=2,ValueFromPipelineByPropertyName... |
PowerShellCorpus/PoshCode/Get-Delegate_1.ps1 | Get-Delegate_1.ps1 | #requires -version 3
function Get-Delegate {
<#
.SYNOPSIS
Create an action[] or func[] delegate for a psmethod reference.
.DESCRIPTION
Create an action[] or func[] delegate for a psmethod reference.
.PARAMETER Method
A PSMethod reference to create a delegate for. This parameter accepts pipeline input.
.PARAM... |
PowerShellCorpus/PoshCode/Show-NodeXLMap.ps1 | Show-NodeXLMap.ps1 | # Author: Doug Finke http://www.dougfinke.com/blog/
# Originally Posted: 08/13/08 (Microsoft Research .NetMap and PowerShell)
# http://www.dougfinke.com/blog/?p=465
# Modified by Steven Murawski http://www.mindofroot.com
# Updated to use the new project name "NodeXL"
# Added support for coloring the labels
# By a... |
PowerShellCorpus/PoshCode/Exchange Services.ps1 | Exchange Services.ps1 | #Requires input from the user
$Server = read-host "Enter Exchange Server Name"
#Finds only the services that contain "Exchange"
$Status = (Get-Service -ComputerName $server |Where-object {$_.Displayname -like "*Exchange*"})
#Displays which Exchange Services are stopped
foreach ($Name in $status) {
IF (... |
PowerShellCorpus/PoshCode/Get-WMIVersions.ps1 | Get-WMIVersions.ps1 | param ( $Credential, $ComputerName )
# The official way to detect .NET versions is to look at their known location on the hard drive as per
# this article: http://msdn.microsoft.com/en-us/kb/kb00318785.aspx
# thanks to David M (http://twitter.com/makovec) for the WQL
$query = "select name from win32_directory ... |
PowerShellCorpus/PoshCode/2nd Line Support.ps1 | 2nd Line Support.ps1 | ##Creates variable for filename
$date = (get-date).tostring("yyyy-MM-dd")
$filename = "H:\\dailychecks\\checks_$date.xls"
## Imports exchange modules
Import-Module "\\\\emailserver\\c$\\PS Modules\\vamail.videoarts.info.psm1"
## Start Internet Explorer to check that Video Arts website is up
Start-Proces... |
PowerShellCorpus/PoshCode/Get-StrictMode_1.psm1.ps1 | Get-StrictMode_1.psm1.ps1 | function Get-Version {
<#
.SYNOPSIS
V2.0 Incorporate Version() and ToString() Methods, 1 Jan 2012.
A very simple module to retrieve the Set-StrictMode setting of the user
session.
.DESCRIPTION
This procedure is necessary as there is, apparently, no equivalent Power-
Shell variable for this and it enables the s... |
PowerShellCorpus/PoshCode/ISE NativeConsole Hooks.ps1 | ISE NativeConsole Hooks.ps1 | # Uses NativeConsole, which is available under a bunch of Open Source licenses
# http://poshconsole.codeplex.com/SourceControl/changeset/view/f9bb2b127402#Huddled/Interop/NativeConsole.cs
add-type -Path ~\\Projects\\PoshConsole\\Huddled\\Interop\\NativeConsole.cs
$NativeConsole = New-Object Huddled.Interop.NativeC... |
PowerShellCorpus/PoshCode/Get-NetworkStatistics.ps1 | Get-NetworkStatistics.ps1 | function Get-NetworkStatistics
{
[OutputType('System.Management.Automation.PSObject')]
[CmdletBinding(DefaultParameterSetName='name')]
param(
[Parameter(Position=0,ValueFromPipeline=$true,ParameterSetName='port')]
[System.Int32]$Port='*',
[Parameter(Position=0,ValueFromPipeline=$true,ParameterSet... |
PowerShellCorpus/PoshCode/Reflection Module_3.ps1 | Reflection Module_3.ps1 | #requires -version 2.0
# ALSO REQUIRES Autoload for some functionality
# You should create a Reflection.psd1 with the contents: @{ RequiredModules = @("Autoload"); GUID="64b5f609-970f-4e65-b02f-93ccf3e60cbb"; ModuleVersion="3.5.0.0" }
#History:
# 1.0 - First public release (March 19, 2010)
# 2.0 - Private Build
... |
PowerShellCorpus/PoshCode/Out-DataTable_6.ps1 | Out-DataTable_6.ps1 | #######################
<#
.SYNOPSIS
Creates a DataTable for an object
.DESCRIPTION
Creates a DataTable based on an objects properties.
.INPUTS
Object
Any object can be piped to Out-DataTable
.OUTPUTS
System.Data.DataTable
.EXAMPLE
$dt = Get-Alias | Out-DataTable
This example creates a DataTable fro... |
PowerShellCorpus/PoshCode/PerformanceTracking.psm1.ps1 | PerformanceTracking.psm1.ps1 | $Parser = [System.Management.Automation.PsParser]
$script:lastMemory = Get-Process -id $PID
$global:LastTweets = new-object System.Collections.Generic.List[PSObject]
$global:PerformanceHistory = @{}
if(!(Test-Path Variable:PrePerformanceTrackingPrompt -EA 0)){
$Global:PrePerformanceTrackingPrompt = ${Function... |
PowerShellCorpus/PoshCode/Manage ASP_1.NET Providers.ps1 | Manage ASP_1.NET Providers.ps1 | # Manage_ASP_NET_Providers.ps1
# by Chistian Glessner
# http://iLoveSharePoint.com
# have to be initaized. If you want to change the app config you have to restart PowerShell
param($appConfigPath=$(throw "-appConfigPath is mandatory"))
{
# App config path have to be set before loading System.Web.dll
[S... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.