full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/group-byobject.ps1 | group-byobject.ps1 | #groups by a set of properties, but returns then rather than as a string, as seperate properties on an object with _count , and _group for the original
#ones returned from group object
#TODO: rewrite as an advanced function
function group-byobject ([object[]]$property,[switch]$includeGroup,[switch]$includeCount)
... |
PowerShellCorpus/PoshCode/An example for you.ps1 | An example for you.ps1 | \n#Requires -version 1.0\n## New-PoshCode (formerly Send-Paste)\n##############################################################################################################\n## Uploads code to the PowerShell Script Repository and returns the url for you.\n#############################################################... |
PowerShellCorpus/PoshCode/PrinterQueStatistics.ps1 | PrinterQueStatistics.ps1 | #Printer Statistic checking script by Henrik Pedersen Ċmark
#This script is used to check how many times all printerques on the selected server has been used the latest X months
#First it gets all the events from the remote server's eventlog that are of ID 10 (successful print) and of the type "Print".
#Then it ch... |
PowerShellCorpus/PoshCode/Set-AttachedProperty.ps1 | Set-AttachedProperty.ps1 | #function Set-AttachedProperty {
[CmdletBinding()]
PARAM(
[Parameter(Position=0,Mandatory=$true)
[System.Windows.DependencyProperty]
$Property
,
[Parameter(Mandatory=$true,ValueFromPipeline=$true)
$Element
)
DYNAMICPARAM {
$paramDictionary = new-object System.Management.Automation.RuntimeDe... |
PowerShellCorpus/PoshCode/Enable PS Remoting_1.ps1 | Enable PS Remoting_1.ps1 | #Run winrm quickconfig defaults
echo Y | winrm quickconfig
#Run enable psremoting command with defaults
enable-psremoting -force
#Enabled Trusted Hosts for Universial Access
cd wsman:
cd localhost\\client
Set-Item TrustedHosts * -force
restart-Service winrm
echo "Complete"
|
PowerShellCorpus/PoshCode/40c64868-c29e-4233-90ad-5097bb26827e.ps1 | 40c64868-c29e-4233-90ad-5097bb26827e.ps1 | Param($user,
$password = $(Read-Host "Enter Password" -asSec),
$filter = "(objectclass=user)",
$server = $(throw '$server is required'),
$path = $(throw '$path is required'),
[switch]$all,
[switch]$verbose)
function GetSecurePass ($SecurePassword) {
$Ptr = [System.Run... |
PowerShellCorpus/PoshCode/TabExpansion for V2CTP_6.ps1 | TabExpansion for V2CTP_6.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-LocalGroupMember_3.ps1 | Get-LocalGroupMember_3.ps1 | function Get-LocalGroupMember
<#
.Synopsis
Get the local group membership.
.Description
Get the local group membership.
.Parameter ComputerName
Name of the Computer to get group members (Default localhost.)
.Parameter Group
... |
PowerShellCorpus/PoshCode/Import-Instapaper.ps1 | Import-Instapaper.ps1 | #
# # ##### # # # # # # ## # #
# # # # ## ## # ## # # # # ## #
# # # # # ## # # # # # # # # # # #
####### # # # # # # # # # ###### # # #
# # # # # # # # ## # # # # ##
# # ##### # # # # ... |
PowerShellCorpus/PoshCode/Users_Contacts from CSV_1.ps1 | Users_Contacts from CSV_1.ps1 | #=============================================================================#
#=============================================================================#
#=============================================================================#
#
# SCRIPT : CreateOrUpdateUsersOrContacts.ps1
# LAST UPDATE : 9/18/2009... |
PowerShellCorpus/PoshCode/Autoload (beta 8).ps1 | Autoload (beta 8).ps1 | #Requires -Version 2.0
## Version History
## beta 8 - 2010.09.20
## Finally fixed the problem with aliases that point at autoloaded functions!
## beta 7 - 2010.06.03
## Added some help, and a function to force loading "now"
## Added a function to load AND show the help...
## beta 6 -... |
PowerShellCorpus/PoshCode/Get-OnlineHelp_2.ps1 | Get-OnlineHelp_2.ps1 | ## An update using New-WebServiceProxy to the MSDN ContentService instead of HttpRest
## See: http: //services.msdn.microsoft.com/ContentServices/ContentService.asmx
## This is a VERY EARLY prototype of a function that could retrieve cmdlet help from TechNet ...
## and hypothetically, other online help sites which... |
PowerShellCorpus/PoshCode/Get-RemoteRegistry_2.ps1 | Get-RemoteRegistry_2.ps1 | ## Get-RemoteRegistry
########################################################################################
## Version: 2.1
## + Fixed a pasting bug
## + I added the "Properties" parameter so you can select specific registry values
## NOTE: you have to have access, and the remote registry service has to be r... |
PowerShellCorpus/PoshCode/Xml Module 4.1.ps1 | Xml Module 4.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.
# IMP... |
PowerShellCorpus/PoshCode/Del. TrailingBlank (ISE).ps1 | Del. TrailingBlank (ISE).ps1 | function Delete-TrailingBlanks
{
$editor = $psISE.CurrentFile.Editor
$caretLine = $editor.CaretLine
# First trial. Works.
# $newText = @()
# foreach ( $line in $editor.Text.Split("`n") )
# {
# $newText += $line -replace ("\\s+$", "")
# }
# $editor.Text = [String]::J... |
PowerShellCorpus/PoshCode/New-ODataServiceProxy.ps1 | New-ODataServiceProxy.ps1 | function New-ODataServiceProxy {
#.Synopsis
# Creates a proxy class for an odata web service
# YOU NEED TO BE VERY CAREFUL NOT TO OUTPUT THE PROXY OBJECT TO THE POWERSHELL HOST!
#.Description
# Uses the data service client utility (DataSvcUtil.exe) to generate a proxy class (and types for all objects) for an O... |
PowerShellCorpus/PoshCode/TabExpansion for V2CTP_4.ps1 | TabExpansion for V2CTP_4.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/Add-ObjectCollector.ps1 | Add-ObjectCollector.ps1 | ##############################################################################\n##\n## Add-ObjectCollector\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\nAdds... |
PowerShellCorpus/PoshCode/New-Choice.ps1 | New-Choice.ps1 | function New-Choice {
<#
.SYNOPSIS
The New-Choice function is used to provide extended control to a script author who writing code
that will prompt a user for information.
.PARAMETER Choices
An Array of Choices, ie Yes, No and Maybe
.PARAMETER Caption
Caption to present to end ... |
PowerShellCorpus/PoshCode/lazywinadmin.com.ps1 | lazywinadmin.com.ps1 | Get-WmiObject Win32_Service -ComputerName . |`
where {($_.startmode -like "*auto*") -and `
($_.state -notlike "*running*")}|`
select DisplayName,Name,StartMode,State|ft -AutoSize
|
PowerShellCorpus/PoshCode/Get-StructFromMemory.ps1 | Get-StructFromMemory.ps1 | function Get-StructFromMemory
{
<#
.SYNOPSIS
Marshals data from an unmanaged block of memory in an arbitrary process to a newly allocated managed object of the specified type.
Author: Matthew Graeber (@mattifestation)
License: BSD 3-Clause
.DESCRIPTION
Get-StructFromMemory is similar to the Marshal.Ptr... |
PowerShellCorpus/PoshCode/Get-Parameter_5.ps1 | Get-Parameter_5.ps1 | function Get-Parameter ( $Cmdlet, [switch]$ShowCommon ) {
foreach ($paramset in (Get-Command $Cmdlet).ParameterSets){
$Output = @()
foreach ($param in $paramset.Parameters) {
if ( !$ShowCommon ) {
if ($param.aliases -match "vb|db|ea|wa|ev|wv|ov|ob") { continue }
}
$process = "" | Select-Object ... |
PowerShellCorpus/PoshCode/New-GenericObject.ps1 | New-GenericObject.ps1 | ##############################################################################\n##\n## New-GenericObject\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nCreate... |
PowerShellCorpus/PoshCode/Start-Presentation_1.ps1 | Start-Presentation_1.ps1 | if(-not(get-command New-System.Windows.Window -EA 0)){ Import-Module PowerBoots }
Add-BootsTemplate $PSScriptRoot\\PresentationFrame.xaml
$name = [System.Windows.Navigation.JournalEntry]::NameProperty
[double]$global:zoomLevel = 1
$SlideCount = 0
function Start-Zoom {
PARAM(
[Parameter(Position=0)]
... |
PowerShellCorpus/PoshCode/Set Active Sync DeviceID.ps1 | Set Active Sync DeviceID.ps1 | # Requires a connection to Exchange Server, or Exchange Management Shell
$s = New-PSSession -ConfigurationName Microsoft.Exchange -Name ExchMgmt -ConnectionUri http://ex14.domain.local/PowerShell/ -Authentication Kerberos
Import-PSSession $s
# Get all Client Access Server properties for all mailboxes with an Act... |
PowerShellCorpus/PoshCode/Upgrade VM's to v7.ps1 | Upgrade VM's to v7.ps1 | Function PowerOn-VM($vm){
Start-VM -VM $vm -Confirm:$false -RunAsync | Out-Null
do {
$vmview = get-VM $vm | Get-View
$status = $vmview.Guest.ToolsStatus
Write-Host $vm is starting! -ForegroundColor Yellow
sleep 5
}until(($status -match "toolsOld") -or ($status -match "toolsOk"))
... |
PowerShellCorpus/PoshCode/Select-TextOutput.ps1 | Select-TextOutput.ps1 | ##############################################################################\n##\n## Select-TextOutput\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... |
PowerShellCorpus/PoshCode/WCF code coverage.ps1 | WCF code coverage.ps1 | param($msBuildTarget, $configurationName, [bool]$deleteInstrumentedAssemblies)
#-------------------------------------
# Script to compile coverage for a WCF
# solution running in IIS.
# See:
# http://geekswithblogs.net/EltonStoneman/archive/2011/10/14/end-to-end-wcf-code-coverage-with-powershell.aspx
#-------... |
PowerShellCorpus/PoshCode/38d536b5-87f9-4725-b346-64260dcc55ec.ps1 | 38d536b5-87f9-4725-b346-64260dcc55ec.ps1 | function Invoke-JQuery
{
<#
.SYNOPSIS
Function to Invoke JQuery commands via IE COM
.DESCRIPTION
Invokes JQuery (or plain Javascript) commands via InternetExplorer.Application COM object,
after initial injection of JQuery reference in header section.
Useful to utilize JQuery selec... |
PowerShellCorpus/PoshCode/New-MAML.ps1 | New-MAML.ps1 | #Requires -version 2.0
#Generates External MAML Powershell help file for any loaded cmdlet or function
#Note: Requires Joel Bennet's New-XML script from http: //www.poshcode.com/1244
#place New-XML in same directory as New-MAML
#Once the XML/MAML file is generated, you'll need to fill in the TODO items and the para... |
PowerShellCorpus/PoshCode/LibraryMSCS_1.ps1 | LibraryMSCS_1.ps1 | # ------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller
### </Author>
### <Description>
### Defines functions for working with Microsoft Cluster Service (MSCS)
### </Description>
### <Usage>
### . ./LibraryMSCS.ps1
### </Usage>
### </Script>
# --... |
PowerShellCorpus/PoshCode/Connect-AccessDB_1.ps1 | Connect-AccessDB_1.ps1 | # Functions for connecting to and working with Access databases
# Matt Wilson
# May 2009
function Connect-AccessDB ($global:dbFilePath) {
# Test to ensure valid path to database file was supplied
if (-not (Test-Path $dbFilePath)) {
Write-Error "Invalid Access database path specified. Please supply full a... |
PowerShellCorpus/PoshCode/running regions in ISE.ps1 | running regions in ISE.ps1 | function invoke-caretline
{
invoke-expression $([Regex]::Split($psISE.CurrentOpenedFile.Editor.text,"`r`n" )[$psISE.CurrentOpenedFile.Editor.caretline-1])
}
$psISE.CustomMenu.Submenus.Add("Run single line", {invoke-caretline} , 'f7')
function invoke-region([int] $num)
{
$ed = $psISE.CurrentOpenedFile.Editor
$l... |
PowerShellCorpus/PoshCode/Clear-XCAttributes.ps1 | Clear-XCAttributes.ps1 | param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()] $User,
[switch]$ClearXCAttributes
)
begin{
$Global:LegacyXCUsers = @()
# attributes to be nulled according to:
# http://blogs.technet.com/b/exchange/archive/2006/10/13/3395089.aspx
$XCattributes=@(
"adminDisplayName","altRecip... |
PowerShellCorpus/PoshCode/get-uuid_allHVs_1.ps1 | get-uuid_allHVs_1.ps1 | #The PowerShell Talk
#Building a HyperVisor Independent Script
#
#This script will take a VM (or host) object from the pipline,
#and from that determine if you're connected to XenServer
#or VMware, and return the apropriate UUID.
Begin {
#VMware VM Host (ESX) UUID
$VMHost_UUID = @{
Name = "VMHo... |
PowerShellCorpus/PoshCode/Get-WMIVersions_1.ps1 | Get-WMIVersions_1.ps1 | #Requires -Version 2
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... |
PowerShellCorpus/PoshCode/Send-HTMLFormattedEmail_2.ps1 | Send-HTMLFormattedEmail_2.ps1 | ##################################################
# cmdlets
##################################################
#-------------------------------------------------
# Send-HTMLFormattedEmail
#-------------------------------------------------
# Usage: Send-HTMLFormattedEmail -?
#------------------------------------... |
PowerShellCorpus/PoshCode/WinFirewall-Disabled.ps1 | WinFirewall-Disabled.ps1 | function WinFirewall-Disabled(){
param (
$computer
)
c:\\PsTools\\PsExec.exe \\\\"$computer" sc config sharedaccess start= disabled
}
|
PowerShellCorpus/PoshCode/chkhash_5.ps1 | chkhash_5.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/Write-Twilight.ps1 | Write-Twilight.ps1 | #Write-Twilight
while(1){
$wc = Get-Random -Minimum (Get-Random -Minimum 1 -Maximum 3) -Maximum (Get-Random -Minimum 4 -Maximum 14)
for($y=0; $y-lt$wc; $y++){
$word = ""
$max = Get-Random -Minimum 5 -Maximum 11
$wl = Get-Random -Minimum 1 -Maximum $max
fo... |
PowerShellCorpus/PoshCode/Resizer of pictures.ps1 | Resizer of pictures.ps1 | [reflection.assembly]::LoadWithPartialName(”System.Drawing”)
$SizeLimit=1280 # required size of picture's long side
$logfile=”resizelog.txt” # log file for errors
$toresize=$args[0] # list of directories to find and resize images. can be empty
if ([string]$toresize -eq ... |
PowerShellCorpus/PoshCode/Write-DataTable_4.ps1 | Write-DataTable_4.ps1 | #######################
<#
.SYNOPSIS
Writes data only to SQL Server tables.
.DESCRIPTION
Writes data only to SQL Server tables. However, the data source is not limited to SQL Server; any data source can be used, as long as the data can be loaded to a DataTable instance or read with a IDataReader instance.
.INPUTS... |
PowerShellCorpus/PoshCode/MoveJunkEmail.ps1 | MoveJunkEmail.ps1 | <######################################################
Name: MoveJunkEmail.ps1
Author: Shawn Harris
Date: 15 Oct 2012
Purpose: Move specified messages from JunkEmail to another
folder. Criteria can be filtered with the restricted property.
######################################################>
#Assembly can ... |
PowerShellCorpus/PoshCode/Logger.psm1 0.3.ps1 | Logger.psm1 0.3.ps1 | <#
Name : Universal Log4Net Logging Module (Logger.psm1)
Version : 0.3
Author : Joel Bennett (MVP)
Site : http://www.HuddledMasses.org/
Version History:
0.3 - Cleanupable release.
Added Udp, Email, Xml and RollingXml, as well as a "Chainsaw":http`://logging.apache.org/log... |
PowerShellCorpus/PoshCode/New-PInvoke.ps1 | New-PInvoke.ps1 | function New-PInvoke
{
<#
.Synopsis
Generate a powershell function alias to a Win32|C api function
.Description
Creates C# code to access a C function, and exposes it via a powershell function
.Example
New-PInvoke -Library User32.dll -Signature "int GetSystemMetrics(uint ... |
PowerShellCorpus/PoshCode/vibackup-lx_2.ps1 | vibackup-lx_2.ps1 | Param (
$viServer,
$bakVM,
$lxDest
)
#region check
if (!$viServer) { $viServer = Read-Host -Prompt "VI Server " }
if (!$bakVM) { $bakVM = Read-Host -Prompt "VM to Backup " }
if (!$lxDest) { $lxDest = Read-Host -Prompt "Backup Path (ex. /srv/backup) " }
#endregion
#region globalvars
$encoding = "OEM"
... |
PowerShellCorpus/PoshCode/Convert-BounceToX_8.ps1 | Convert-BounceToX_8.ps1 | # $Id: Convert-BounceToX500.ps1 610 2010-11-16 00:39:19Z jon $
# $Revision: 610 $
#.Synopsis
# Convert Bounce to X500
#.Description
# Convert URL Encoded address in a Bounce message to an X500 address
# that can be added as an alias to the mail-enabled object
#.Parameter bounceAddress
# URL Encoded bounce... |
PowerShellCorpus/PoshCode/UIAutomation 1.8.ps1 | UIAutomation 1.8.ps1 | ## UI Automation v 1.8 -- REQUIRES the Reflection module (current version: http://poshcode.org/3174 )
##
# WASP 2.0 is getting closer, but this is still just a preview:
# -- a lot of the commands have weird names still because they're being generated ignorantly
# -- eg: Invoke-Toggle.Toggle and Invoke-Invoke.Invo... |
PowerShellCorpus/PoshCode/finddupe_6.ps1 | finddupe_6.ps1 | None |
PowerShellCorpus/PoshCode/cd command with history.ps1 | cd command with history.ps1 | ########################################################
# Custom 'cd' command to maintain directory history
#
# Usage:
# cd no args means cd $home
# cd <name> changes to the directory specified by <name>
# cd -l list your directory history
# cd -# change to the history entry specified... |
PowerShellCorpus/PoshCode/Out-DataTable_5.ps1 | Out-DataTable_5.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/VHDFunctions.psm1.ps1 | VHDFunctions.psm1.ps1 | <#
Name: VHDFunctions.psm1
Author: Rich Kusak (rkusak@cbcag.edu)
Created: 2009-10-23
LastEdit: 2009-11-02 15:54
Included Functions:
Dismount-VHD
Initialize-VHD
Mount-VHD
New-VHD
Set-VHDBootConfiguration
Test-VHD
#>
<#
.SYNOPSIS
Dismount a VHD file from the system.
.DESCRIPTION
This f... |
PowerShellCorpus/PoshCode/Get-Parameter_3.ps1 | Get-Parameter_3.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/Set-PowerGUIWelcomePage.ps1 | Set-PowerGUIWelcomePage.ps1 | ########################################################
# Modifies the default PowerGUI admin console
# welcome screen to the mht file you supply
# Details available at:
# http://dmitrysotnikov.wordpress.com/2009/02/11/rebranding-powergui-consolerebranding-powergui-console/
######################################... |
PowerShellCorpus/PoshCode/Set-Computername_11.ps1 | Set-Computername_11.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/Report-DecomVMs.ps1 | Report-DecomVMs.ps1 | #========================================================================
# Created on: 6/8/2012 9:45 AM
# Created by: Clint Jones
# Organization: Virtually Genius!
# Filename: Report-DecomVMs
#========================================================================
#Load PowerCLI
Add-PSSnapin VMware.V... |
PowerShellCorpus/PoshCode/Findup_16.ps1 | Findup_16.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/Quest Dynamic Group 004.ps1 | Quest Dynamic Group 004.ps1 | <#
2012.07.06
Information will be uploaded shortly.
#>
|
PowerShellCorpus/PoshCode/SqlProxy_5.psm1.ps1 | SqlProxy_5.psm1.ps1 | # ---------------------------------------------------------------------------
### <Author>
### Chad Miller
### </Author>
### <Description>
### Based on functions in SQLPSX. SqlProxy.psm1 module is used for administering
### SQL Server logins, users, and roles. Designed to be used with PS Remoting.
### All actio... |
PowerShellCorpus/PoshCode/Join-Collections.ps1 | Join-Collections.ps1 | #requires -version 2.0
#.Note
# Depends on ConvertFrom-HashTable http://poshcode.org/1118
#.Synopsis
# Performs an inner join on two collections of objects based on a common key column.
#.Description
# Takes two sets of objects where there are multiple "rows" and where each set has a shared column where th... |
PowerShellCorpus/PoshCode/Easy Migration Tool v_1.1.ps1 | Easy Migration Tool v_1.1.ps1 | #Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: Richard Yaw
# Generated On: 09/12/2010
#
# Easy Migration Script for VMware (Version 2.1)
# - Added a "Reload Tasks" feature.
# - Fixed issue with the Undo feature for S... |
PowerShellCorpus/PoshCode/ConvertTo-Hex.ps1 | ConvertTo-Hex.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/Function Run-Script_3.ps1 | Function Run-Script_3.ps1 | #################################################################################
# This function should be included in the PowerShell ISE profile.ps1 and it will
# display the start and end times of any scripts started by clicking 'Run Script'
# in the Add-ons Menu, or F2; additionally they will be logged to the S... |
PowerShellCorpus/PoshCode/Hack ESXi_4.ps1 | Hack ESXi_4.ps1 | $screen = " You see here a virtual switch. ------------ ------
#...........| |....|
--------------- ###------------ |...(|
|..%...........|########## ###-@...|
... |
PowerShellCorpus/PoshCode/Assert.ps1 | Assert.ps1 | function Assert {
#.Example
# set-content C:\\test2\\Documents\\test2 "hi"
# C:\\PS>assert { get-item C:\\test2\\Documents\\test2 } "File wasn't created by Set-Content!"
#
[CmdletBinding()]
param(
[Parameter(Position=0,ParameterSetName="Script",Mandatory=$true)]
[ScriptBlock]$condition
,
[Parameter(... |
PowerShellCorpus/PoshCode/VMWare VMNET Adapters.ps1 | VMWare VMNET Adapters.ps1 | # see http://msdn2.microsoft.com/en-us/library/bb201634.aspx
#
# *NdisDeviceType
#
# The type of the device. The default value is zero, which indicates a standard
# networking device that connects to a network.
#
# Set *NdisDeviceType to NDIS_DEVICE_TYPE_ENDPOINT (1) if this device is an
# endpoint device and ... |
PowerShellCorpus/PoshCode/Paint board.ps1 | Paint board.ps1 | function frmMain_Show {
Add-Type -AssemblyName PresentationFramework
$win = New-Object Windows.Window
$ink = New-Object Windows.Controls.InkCanvas
#
#ink
#
$ink.MinWidth = $ink.MinHeight = 450
#
#win
#
$win.Content = $ink
$win.SizeToContent = "WidthAndHeight"
$win.Title = "Paint... |
PowerShellCorpus/PoshCode/Find Local Group Members_6.ps1 | Find Local Group Members_6.ps1 | # Author: Hal Rottenberg
# Purpose: Find matching members in a local group
# Used tip from RichS here: http://powershellcommunity.org/Forums/tabid/54/view/topic/postid/1528/Default.aspx
# Change these two to suit your needs
$ChildGroups = "Domain Admins", "Group Two"
$LocalGroup = "Administrators"
$MemberName... |
PowerShellCorpus/PoshCode/Change-ServicePassword_1.ps1 | Change-ServicePassword_1.ps1 | Param([string]$server,[string]$service,[string]$user,[string]$password)
Begin{
function ChangeServicePassword{
Param([string]$srv,[string]$ms,[string]$usr,[string]$pwd)
# Setup for WMI
$class = "Win32_Service"
$method = "change"
$computer = $srv
$fil... |
PowerShellCorpus/PoshCode/Monitor-FileSize_3.ps1 | Monitor-FileSize_3.ps1 | function Monitor-FileSize
{
<#
.Synopsis
Checks the file size of a given file until it reaches the specified size
.Description
Checks the file size of a given file until it reaches the specified size. AT that point, it alerts the user as to what the original file-size-boundry was and what it currentl... |
PowerShellCorpus/PoshCode/TabExpansion_1.ps1 | TabExpansion_1.ps1 | ## Tab-Completion
#################
## Please dot souce this script file.
## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list.
## What this can do is:
##
## [datetime]::n<tab>
## [datetime]::now.d<tab>
## $foo[0].<tab>
## $foo[0].n.b<tab>
## $function:a<tab>
##... |
PowerShellCorpus/PoshCode/Make a phone call.ps1 | Make a phone call.ps1 | <#
.NOTES
AUTHOR: Sunny Chakraborty(sunnyc7@gmail.com)
WEBSITE: http://tekout.wordpress.com
VERSION: 0.1
CREATED: 17th April, 2012
LASTEDIT: 17th April, 2012
Requires: PowerShell v2 or better
.CHANGELOG
4/17/2012 Try passing powershell objects to PROTO API and pass the variables to .JS file
P... |
PowerShellCorpus/PoshCode/The other Post.ps1 | The other Post.ps1 | $insParm = '/s /v"/qn /norestart"'
$updList = get-cluster -name $YouClusterNameHere | get-vm |
where-object {$_.powerstate -eq "PoweredON"} |
foreach-object { get-view $_.ID } |
where { $_.guest.toolsstatus -match "toolsOld" }
foreach ($uVM in $updList)
{
$uVM.name
$uVM.UpgradeTools_Task($insParm)
... |
PowerShellCorpus/PoshCode/SharePoint Large Lists.ps1 | SharePoint Large Lists.ps1 | [reflection.assembly]::loadwithpartialname("Microsoft.SharePoint")
$cs = [microsoft.sharepoint.administration.spwebservice]::ContentService
$global:largeListThreshhold = 2000
function Is-Admin([Microsoft.SharePoint.SPRoleAssignment]$roleAssignment)
{
return (($roleAssignment.roledefinitionbindings | where { ($_... |
PowerShellCorpus/PoshCode/Auto ISE Preferences.ps1 | Auto ISE Preferences.ps1 | ##############################################################
#Author: Ravikanth Chaganti (http://www.ravichaganti.com/blog)
#Script: SaveISEPrefs.ps1
#Description: PowerShell ISE profile script to automatically
# archive changes to ISE preferences such as color
# schemes, font, etc
#####... |
PowerShellCorpus/PoshCode/TabExpansion_8.ps1 | TabExpansion_8.ps1 | ## Tab-Completion
#################
## Please dot souce this script file.
## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list.
##
## What this can do is:
##
## [datetime]::n<tab>
## [datetime]::now.d<tab>
## $a = New-Object "Int32[,]" 2,3; $b = "PowerShell","Pow... |
PowerShellCorpus/PoshCode/Get-DirSize.ps1 | Get-DirSize.ps1 | function Get-DirSize {
<#
.Synopsis
Gets a list of directories and sizes.
.Description
This function recursively walks the directory tree and returns the size of
each directory found.
.Parameter path
The path of the root folder to start scanning.
.Example
# Get the largest folder under the user pro... |
PowerShellCorpus/PoshCode/NTFS ACLs Folder Tree_4.ps1 | NTFS ACLs Folder Tree_4.ps1 | #######################################
# TITLE: listACL.ps1 #
# AUTHOR: Santiago Fernandez Muñoz #
# #
# DESC: This script generate a HTML #
# report show all ACLs asociated with #
# a Folder tree structure starting in #
# root specified by the user... |
PowerShellCorpus/PoshCode/Get-CertificationAuthori.ps1 | Get-CertificationAuthori.ps1 | #####################################################################
# Get-CertificationAuthority.ps1
# Version 1.0
#
# Retrieves all Enterprise Certification Authorities in cuurent AD forest
#
# Vadims Podans (c) 2009
# http://www.sysadmins.lv/
#################################################################... |
PowerShellCorpus/PoshCode/ConvertTo-Hashtable.ps1 | ConvertTo-Hashtable.ps1 | Param([Parameter(ValueFromPipeline=$true)]$object,[switch]$AsString,[switch]$jagged)
BEGIN { $headers = @() }
PROCESS {
if(!$headers -or $jagged) {
$headers = $object | get-member -type Properties | select -expand name
}
$output = @{}
if($AsString) {
foreach($col in $headers) {
... |
PowerShellCorpus/PoshCode/HuddledTricks_1.ps1 | HuddledTricks_1.ps1 | #Requires -version 2.0
## Stupid PowerShell Tricks
###################################################################################################
## Usage:
## ps Notepad | Hide-App
## Hide-App -Name PowerShell; Wiggle-Mouse 75 100
##############################################################################... |
PowerShellCorpus/PoshCode/Manage ASP_2.NET Providers.ps1 | Manage ASP_2.NET Providers.ps1 | # Manage_ASP_NET_Providers.ps1
# by Chistian Glessner
# http://iLoveSharePoint.com
# have to be initialized. 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
... |
PowerShellCorpus/PoshCode/Windows Startup Script_3.ps1 | Windows Startup Script_3.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/Resolve-Aliases _5.7.ps1 | Resolve-Aliases _5.7.ps1 | #requires -version 2.0
## ResolveAliases Module v 1.7
########################################################################################################################
## Sample Use:
## Resolve-Aliases Script.ps1 | Set-Content Script.Resolved.ps1
## ls *.ps1 | Resolve-Aliases -Inplace
##############... |
PowerShellCorpus/PoshCode/Copy-GroupMembership.ps1 | Copy-GroupMembership.ps1 | <#
.SYNOPSIS
Copy group membership between two accounts.
.DESCRIPTION
This script will copy the group membership from an existing user
account to a new user account.
.PARAMETER ADSPath
This is the LDAP URL to where your user accounts are stored
.PARAMETER NewUser
... |
PowerShellCorpus/PoshCode/Backup all ESXi.ps1 | Backup all ESXi.ps1 | # Change this to where you would like your backups to go.
# There is no versioning so backup theses backups with real backup software (e.g. on an SMB share).
$backupDir = "c:\\backups"
# Get just your ESXi hosts.
$esxiHosts = Get-VMHost | Where { $_ | Get-View -Property Config | Where { $_.Config.Product.ProductL... |
PowerShellCorpus/PoshCode/SQL-Update.ps1 | SQL-Update.ps1 | <#
.SYNOPSIS
Author:...Vidrine
Date:.....2012/04/08
.DESCRIPTION
Function uses the Microsoft SQL cmdlets 'Invoke-SQLcmd' to connect to a SQL database and run an UPDATE statement.
The target record that will be updated is queried based on a table/column named 'ID'. Simply change this to query based on anot... |
PowerShellCorpus/PoshCode/Find-String_1.ps1 | Find-String_1.ps1 | <#
.Synopsis
Searches text files by pattern and displays the results.
.Description
Searches text files by pattern and displays the results.
.Notes
Based on versions from http://weblogs.asp.net/whaggard/archive/2007/03/23/powershell-script-to-find-strings-and-highlight-them-in-the-output.aspx and from http://pos... |
PowerShellCorpus/PoshCode/Reverse filename sequenc_1.ps1 | Reverse filename sequenc_1.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/Set-Wallpaper (CTP2).ps1 | Set-Wallpaper (CTP2).ps1 | #requires -version 2.0
## Set-Wallpaper - set your windows desktop wallpaper
###################################################################################################
## Usage:
## Set-Wallpaper "C:\\Users\\Joel\\Pictures\\Others Stock\\Potter Wasp.jpg" "Stretched"
## ls *.jpg | get-random | Set-Wal... |
PowerShellCorpus/PoshCode/Get-Checksum GUI.ps1 | Get-Checksum GUI.ps1 | <#
.NOTES
Name : Get-Checksum GUI
Author : Bryan Jaudon <bryan.jaudon@gmail.com>
Version : 1.2
Date : 9/14/2012
.SYNOPSIS
GUI file checksum calculation script.
#>
#requires -version 2
$ScriptVersion="1.2"
#Check if Powershell is running in MTA or STA mode. STA is required fo... |
PowerShellCorpus/PoshCode/Get-WmiClassKeyProperty..ps1 | Get-WmiClassKeyProperty..ps1 | ##############################################################################\n##\n## Get-WmiClassKeyProperty\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\n... |
PowerShellCorpus/PoshCode/Compile-Help.ps1 | Compile-Help.ps1 | # Compile-Help.ps1
# by Jeff Hillman
#
# this script uses the text and XML PowerShell help files to generate HTML help
# for all PowerShell Cmdlets, PSProviders, and "about" topics. the help topics
# are compiled into a .chm file using HTML Help Workshop.
param( [string] $outDirectory = ".\\PSHelp", [switch] ... |
PowerShellCorpus/PoshCode/Get-RemoteRegistryChildI.ps1 | Get-RemoteRegistryChildI.ps1 | ##############################################################################\n##\n## Get-RemoteRegistryChildItem\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/Watch-Expression.ps1 | Watch-Expression.ps1 | #############################################################################\n##\n## Watch-Expression\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\nUpdates ... |
PowerShellCorpus/PoshCode/VMware datastore graph.ps1 | VMware datastore graph.ps1 | if ((Test-Path REGISTRY::HKEY_CLASSES_ROOT\\OWC11.ChartSpace.11) -eq $False)
{
Write-Host "This script requires Office Web Components to run correctly, please install these from the following website: http://www.microsoft.com/downloads/details.aspx?FamilyId=7287252C-402E-4F72-97A5-E0FD290D4B76&displaylang=en"... |
PowerShellCorpus/PoshCode/Import-VCBImage.ps1 | Import-VCBImage.ps1 | #
# import-VCBImage.ps1 : use the Converter to import a VCB created disk image into a datacenter
#
# Author: LucD
#
# History:
#
# v1.0 20/09/09 first version
#
$I2VImageDir = <directory where the VCB images are stored>
$I2VShare = <Sharename of the $I2VImageDir directory>
$tgtDatacenter = <... |
PowerShellCorpus/PoshCode/345ba1e2-f03d-4a3c-b553-da7d433d2436.ps1 | 345ba1e2-f03d-4a3c-b553-da7d433d2436.ps1 | Get-PSDrive -PSProvider FileSystem | foreach { $_.Root } | `
Get-ChildItem -Recurse -Include '*.ps1', '*.psm1', '*.ps1xml' | `
where { Select-String -Path $_ -SimpleMatch -Pattern `
'VMware.VimAutomation.Types.', `
'VMware.VimAutomation.Client20.', `
'[Datastore]' }
|
PowerShellCorpus/PoshCode/5566cee5-63c0-4a96-8ed6-c53a1f2237b2.ps1 | 5566cee5-63c0-4a96-8ed6-c53a1f2237b2.ps1 | function KillDBConnections([string]$serverName, [string]$DBName)
{
$ConnectionString = "Data Source=$serverName;Initial Catalog=master;Integrated Security=SSPI"
$connection = New-Object System.Data.SqlClient.SqlConnection($ConnectionString);
$command = New-Object System.Data.SqlClient.SqlComman... |
PowerShellCorpus/PoshCode/Get-Excuse.ps1 | Get-Excuse.ps1 | Function Get-Excuse {
<#
.Synopsis
Retrieves a BOFH excuse from Jeff Ballard's website (http://jeffballard.us/).
.Description
Uses System.Net.WebRequest to retrieve page content as a string from the predefined URL. By default,
Get-Excuse uses the system defined Proxy Server. Alternate ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.