full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/ciao.ps1 | ciao.ps1 | ########################################################
# Created by Brian English
# Brian.English@charlottefl.com
# eddiephoenix@gmail.com
#
# for Charlotte County Government
# No warranty suggested or implied
########################################################
# Purpose: Cycle through all VMs on a... |
PowerShellCorpus/PoshCode/Resolve-Aliases _2.7.ps1 | Resolve-Aliases _2.7.ps1 | #requires -version 2.0
## ResolveAliases Module v 1.6
########################################################################################################################
## Sample Use:
## Resolve-Aliases Script.ps1 | Set-Content Script.Resolved.ps1
## ls *.ps1 | Resolve-Aliases -Inplace
##############... |
PowerShellCorpus/PoshCode/Decrypt Psi Password_1.ps1 | Decrypt Psi Password_1.ps1 | function decrypt-psi ($jid, $pw) {
$OFS = ""; $u = 0;
for($p=0;$p -lt $pw.Length;$p+=4) {
[char]([int]"0x$($pw[$p..$($p+3)])" -bxor [int]$jid[$u++])
}
}
$accounts = ([xml](cat ~\\psidata\\profiles\\default\\accounts.xml))["accounts"]["accounts"]
foreach($account in ($accounts | gm a[0-9]*)) {
... |
PowerShellCorpus/PoshCode/Remove Special Char.ps1 | Remove Special Char.ps1 | gci 'c:\\test\\' -Recurse | % { Rename-Item $_.FullName $($_.Name -replace
'[^\\w\\.]','') }
|
PowerShellCorpus/PoshCode/Export-PSCredential_1.ps1 | Export-PSCredential_1.ps1 | # Author: Hal Rottenberg <hal@halr9000.com>
# Url: http://halr9000.com/article/tag/lib-authentication.ps1
# Purpose: These functions allow one to easily save network credentials to disk in a relatively
# secure manner. The resulting on-disk credential file can only [1] be decrypted
# by the same user account... |
PowerShellCorpus/PoshCode/Test-Prompt_1.ps1 | Test-Prompt_1.ps1 | $choices = [System.Management.Automation.Host.ChoiceDescription[]](
(New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Choose me!"),
(New-Object System.Management.Automation.Host.ChoiceDescription "&No","Pick me!"))
$Answer = $host.ui.PromptForChoice('Caption',"Message",$choices,(1))
Write-... |
PowerShellCorpus/PoshCode/Pipeline and Parameter.ps1 | Pipeline and Parameter.ps1 | Function Test-Func {
param(
[Parameter(ValueFromPipeline=$true, Mandatory=$true, Position=0)]
[string[]]$ComputerName
)
Begin {
Function Do-Process($p) {
"Processing $($p)"
}
}
Process {
if($_) { Do-Process $_ }
}
... |
PowerShellCorpus/PoshCode/set-FSRMQuotaBasedOnSQL.ps1 | set-FSRMQuotaBasedOnSQL.ps1 | #0# init
$error.clear()
cls
$ErrorActionPreference= "Stop" # do zmiany na "SilentlyContinue" lub "Continue" po adaptacji
#/0# #1# sql conn parameters
$dataSource = "Serwer\\SQL01"
$database = "nazwaBazyDanych"
#$authentication = "Integrated Security=SSPI" # preferowana metoda, ale nie zawsze się tak da... |
PowerShellCorpus/PoshCode/Invoke-ISPackage.ps1 | Invoke-ISPackage.ps1 | <#
.SYNOPSIS
Runs an SSIS package from an SQL package store.
.DESCRIPTION
Invoke-ISPackage.ps1 script is a wrapper around dtexec.exe to run an SSIS package.
.EXAMPLE
PowerShell.exe -File "C:\\Scripts\\Invoke-ISPackage.ps1" -PackagePath "SQLPSX\\sqlpsx1" -ServerInstance "Z001\\SQL1"
This example connects to SSIS ... |
PowerShellCorpus/PoshCode/Get-CInfo_2.ps1 | Get-CInfo_2.ps1 | function Get-CInfo {
param($Comp)
Function PC-Name{
param ($compname)
$ADS = Get-ADComputer -Filter {name -eq $compname} -Properties * | Select-Object -Property name
If($ads -eq $null) {$false}
ELSE{$True}
}
$ping = PC-Name $COMP
if ($ping -eq $true) {
Write-Host -ForegroundColor G... |
PowerShellCorpus/PoshCode/Powershell $ UIA.ps1 | Powershell $ UIA.ps1 | $path = "$env:programfiles\\Reference Assemblies\\Microsoft\\Framework\\v3.0"
$TypesAssembly = [Reflection.Assembly]::LoadFile("$path\\UIAutomationTypes.dll")
$ClientAssembly = [Reflection.Assembly]::LoadFile("$path\\UIAutomationClient.dll")
$NS = "System.Windows.Automation"
[System.Diagnostics.Process]::Start(... |
PowerShellCorpus/PoshCode/Set-Extension.ps1 | Set-Extension.ps1 | function Set-Extension {
#.Synopsis
# Change the extension on file paths
#.Example
# ls *.ps1 | Set-Extension bak | ls
#
# Lists all .bak files that correspond to .ps1 scripts
#.Example
# ls *.txt | move -dest { Set-Extension log -path $_.PSPath }
#
# Renames all .txt files by changing their extension t... |
PowerShellCorpus/PoshCode/New-DesktopIni.ps1 | New-DesktopIni.ps1 | $di = [System.IO.FileInfo]"$(split-path $Profile -Parent)\\desktop.ini"\nset-content $di "[.ShellClassInfo]`r`nLocalizedResourceName=1$([char]160)WindowsPowerShell`r`nIconResource=C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe,0`r`n[ViewState]`r`nFolderType=Documents"\n$di.Attributes = $di.Attributes -b... |
PowerShellCorpus/PoshCode/_CTP3_ Invoke-ISE.ps1 | _CTP3_ Invoke-ISE.ps1 | Set-Alias ISE Invoke-ISE
function Invoke-ISE ()
<#
.SYNOPSIS
start ISE from the PS-commandline
.DESCRIPTION
start ISE provide files as parameters or per pipe-line
.NOTES
Author : Bernd Kriszio - http://pauerschell.blogspot.com/
Requires : PowerShell V2 CTP3
and please can someone fix t... |
PowerShellCorpus/PoshCode/74d37072-bf65-4930-9299-29a0ec36260e.ps1 | 74d37072-bf65-4930-9299-29a0ec36260e.ps1 | Function Get-DriveInfo([string]$computer = "localhost") {
PROCESS{
$LogicalDrive = Get-WmiObject –computername $computer Win32_LogicalDisk -filter "DriveType=3"
$PhysicalDrive = Get-WmiObject -class "Win32_DiskDrive" -namespace "root\\CIMV2" -computername $computer
$objResult = @()
foreach ($item... |
PowerShellCorpus/PoshCode/Out-Default URL Launcher.ps1 | Out-Default URL Launcher.ps1 | # Wrapper for Out-Default that saves the last object written
# and handles missing commands if the command is a directory
# or an URL
#
function Out-Default `
{
[CmdletBinding(ConfirmImpact="Medium")]
param(
[Parameter(ValueFromPipeline=$true)] `
[System.Management.Automation.PSObject] $Inp... |
PowerShellCorpus/PoshCode/Convert-BounceToX_11.ps1 | Convert-BounceToX_11.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/Send-Growl _1.0.ps1 | Send-Growl _1.0.ps1 | ## This is the first version of a Growl module (just dot-source to use in PowerShell 1.0)
## Initially it only supports a very simple notice, and I haven't gotten callbacks working yet
## Coming soon:
## * Send notices to other PCs directly
## * Wrap the registration of new messages
## * Figure out the stupid
... |
PowerShellCorpus/PoshCode/TabExpansion for V2CTP3.ps1 | TabExpansion for V2CTP3.ps1 | ## Tab-Completion
#################
## For V2CTP3.
## All or some features 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.
## Some features(relate to '$_' expansion) require the latest... |
PowerShellCorpus/PoshCode/Get-HostsFile_1.ps1 | Get-HostsFile_1.ps1 | Function Get-HostsFile {
<#
.SYNOPSIS
Retrieves the contents of a hosts file on a specified system
.DESCRIPTION
Retrieves the contents of a hosts file on a specified system
.PARAMETER Computer
Computer name to view host file from
.NOTES
Name: Get-HostsFile
Author: Boe Prox
DateCre... |
PowerShellCorpus/PoshCode/Get Stock Quotes.ps1 | Get Stock Quotes.ps1 | function Get-StockQuote {
param($symbols)
process {
$s = new-webserviceproxy -uri http://www.webservicex.net/stockquote.asmx
foreach ($symbol in $symbols) {
$result = [xml]$s.GetQuote($symbol)
$result.StockQuotes.Stock
}
}
}
# Example:
# Get-StockQuote VMW, EMC | select Symbol, Last
|
PowerShellCorpus/PoshCode/sharpsvn, btw PS sucks.ps1 | sharpsvn, btw PS sucks.ps1 | [string]$rootDir = "C:\\Build\\"
[string]$buildDir = "C:\\Build\\build_dir\\"
[string]$outputDir = "C:\\Build\\output_dir\\"
[string]$svnDir = "C:\\Build\\build_dir\\vacuum"
[string]$svnUrl = "http://vacuum-im.googlecode.com/svn/trunk/"
$currentScriptDirectory = Get-Location
[System.IO.Directory]::SetCurrentDir... |
PowerShellCorpus/PoshCode/Get-Weather 2.1.ps1 | Get-Weather 2.1.ps1 | #require -version 2.0
#require -shellid PoshConsole
###################################################################################################
## Get-Weather
## Parse and display the current weather and forecast from yahoo RSS
## Note that you _could_ modify this a bit to return "current condition" and "... |
PowerShellCorpus/PoshCode/Get-LocalGroupMember.ps1 | Get-LocalGroupMember.ps1 | function Get-LocalGroupMember {
param(
# The name of the local group to retrieve members of
[Parameter(Position=0,Mandatory=$true)]
[String]$GroupName = "administrators",
# A filter for the user name(s)
[Parameter(Position=1)]
[String]$UserName = "*",
# The computer to query (defaults ... |
PowerShellCorpus/PoshCode/Get-GoogleSpreadsheets.ps1 | Get-GoogleSpreadsheets.ps1 | #requires -version 2
Function Get-GoogleSpreadSheets {
param(
$userName = $(throw 'Please specify a user name'),
$password = $(throw 'Please specify a password')
)
Add-Type -Path "C:\\Program Files\\Google\\Google Data API SDK\\Redist\\Google.GData.Client.dll"
Add-Type -Path "C:... |
PowerShellCorpus/PoshCode/New-ODataServiceProxy_2.ps1 | New-ODataServiceProxy_2.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/Convert-BounceToX_10.ps1 | Convert-BounceToX_10.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/New-FileShare.ps1 | New-FileShare.ps1 | Function New-FileShare {
#this function returns $True is the share is successfully created
Param([string]$computername=$env:computername,
[string]$path=$(Throw "You must enter a complete path relative to the remote computer."),
[string]$share=$(Throw "You must enter the name of the new share... |
PowerShellCorpus/PoshCode/Xml Module 4.5.ps1 | Xml Module 4.5.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/Set-EnvironmentVariable.ps1 | Set-EnvironmentVariable.ps1 | #requires -version 2
function Set-EnvironmentVariable {
param (
[String] [Parameter( Position = 0, Mandatory = $true )] $Name,
[String] [Parameter( Position = 1, Mandatory = $true )] $Value,
[EnvironmentVariableTarget]
[Parameter( Position = 2 )]
$Target = [EnvironmentVariableTarget]::Process,
... |
PowerShellCorpus/PoshCode/GPRS Online log_9.ps1 | GPRS Online log_9.ps1 | <#
.SYNOPSIS
Get-GprsTime (V4.0 Update for Windows 7 and allow time correction)
(V4.4 'Interval' now incorporate previous 'FormatSpan' function)
(V4.6 'Adjust' pattern will now reject times like '1:300:50')
Check the total connect time of any GPRS SIM devices from a specified date.
Use ... |
PowerShellCorpus/PoshCode/Get-Parameter_14.ps1 | Get-Parameter_14.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)]
[string[]]$Name
,
[Parameter(Position=2,ValueFromPipelineByPr... |
PowerShellCorpus/PoshCode/Update AD Security Group.ps1 | Update AD Security Group.ps1 | #Active Directory Group Name To Be Edited
#Load Active Directory Module
if(@(get-module | where-object {$_.Name -eq "ActiveDirectory"} ).count -eq 0) {import-module ActiveDirectory}
###Functions
function Get-FSMORoles
{
Param (
$Domain
)
$DomainDN = $Domain.defaultNamingContext
$FSMO = @{}
... |
PowerShellCorpus/PoshCode/Get Exchange2003 Servers.ps1 | Get Exchange2003 Servers.ps1 | [Array]$ExchSrvs = @("")
[String]$StrFilter = "(objectCategory=msExchExchangeServer)"
$objRootDSE = [ADSI]"LDAP://RootDSE"
[String]$strContainer = $objRootDSE.configurationNamingContext
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = New-object System.DirectoryService... |
PowerShellCorpus/PoshCode/ConvertTo-GoogleChartNum.ps1 | ConvertTo-GoogleChartNum.ps1 | ## Google Chart API extended value encoding function
#########################################################################
#function ConvertTo-GoogleChartNum{
BEGIN {
## Google's odydecody is a 64 character array
$ody = "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","... |
PowerShellCorpus/PoshCode/Run-Defrag_1.ps1 | Run-Defrag_1.ps1 | # Run-Defrag
# Defragments the targeted hard drives.
#
# Args:
# $server: A target Server 2003 or 2008 system
# $drive: An optional drive letter. If this is blank then all
# drives are defragmented
# $force: If this switch is set then a defrag will be forced
# even if the drive is lo... |
PowerShellCorpus/PoshCode/PS+ImgBurn burn all ISOs.ps1 | PS+ImgBurn burn all ISOs.ps1 | function burn()
{
#get the files and ship them to burn-file
dir -recurse -include *.iso -path c:\\,d:\\,e:\\ | foreach { burn-file $_.FullName }
}
function burn-file($filename)
{
#call img burn with the nessessary arguments
. "c:\\Program Files\\ImgBurn\\ImgBurn.exe" /mode ISOWRITE /WAITFORMEDIA /start /close... |
PowerShellCorpus/PoshCode/Boots & Background Jobs.ps1 | Boots & Background Jobs.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/Write-Log_2.ps1 | Write-Log_2.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/playlist.com music cache.ps1 | playlist.com music cache.ps1 |
#put the playlist.com playlist number into $pl
$pl = 14870805259;
([xml](new-object system.net.webclient).downloadstring("http://pl.playlist.com/pl.php?playlist=$([int]($pl/256))")).playlist.tracklist.track | % {try { $a= $_.tracktitle;$a;(new-object system.net.webclient).downloadfile($_.originallocation,"c:\\mus... |
PowerShellCorpus/PoshCode/Get-Sysinternals.ps1 | Get-Sysinternals.ps1 |
function Get-SysInternals {
param ( $sysIntDir=(join-path $env:systemroot "\\Sysinternals\\") )
if(!(Test-Path -Path $sysIntDir -PathType Container))
{
$null = New-Item -Type Directory -Path $sysIntDir -Force
}
$log = join-path $sysIntDir "changes.log"
Add-Content ... |
PowerShellCorpus/PoshCode/Out-SqlLdrCtlFile.ps1 | Out-SqlLdrCtlFile.ps1 | param($fileName)
Add-Type -Path "C:\\Oracle\\Oracle.ManagedDataAccess.dll"
#Change these values
$userID = "yourOracleUserID"
$password ="yourOraclePassword"
$dataSource ="yourOracleDB"
#Assumes Table name is same as file name without extension
#and ctl file will output to same directory with ctl extension
... |
PowerShellCorpus/PoshCode/PSTUtility.psm1.ps1 | PSTUtility.psm1.ps1 | #=============================================================================
#
# PST Utilities - For Discovery, Import, Removal
#
# Dan Thompson
# dethompson71 at live dot com
#
# This collection of tools for importing PSTs has been pieced together
# over many months of trial and error.
#
# Goal is to get ... |
PowerShellCorpus/PoshCode/Audit NTFS on Shares_1.ps1 | Audit NTFS on Shares_1.ps1 | $Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$wSheet = $Excel.Worksheets.Item(1)
$wSheet.Cells.item(1,1) = "Folder Path:"
$wSheet.Cells.Item(1,2) = "Users/Groups:"
$wSheet.Cells.Item(1,3) = "Permissions:"
$wSheet.Cells.Item(1,4) = "Permissions Inherited:"
... |
PowerShellCorpus/PoshCode/Invoke-WMSettingsChange.ps1 | Invoke-WMSettingsChange.ps1 | #requires -version 2
if (-not ("win32.nativemethods" -as [type])) {
# import sendmessagetimeout from win32
add-type -Namespace Win32 -Name NativeMethods -MemberDefinition @"
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(
IntPtr ... |
PowerShellCorpus/PoshCode/Get-Credential 2.1.ps1 | Get-Credential 2.1.ps1 | ## Get-Credential
## An improvement over the default cmdlet which has no options ...
###################################################################################################
## History
## v 2.1 Fix the comment help and parameter names to agree with each other (whoops)
## v 2.0 Rewrite for v2 to replace... |
PowerShellCorpus/PoshCode/Bulk Storage vMotion .ps1 | Bulk Storage vMotion .ps1 | #========================================================================
# Created on: 5/31/2012 4:31 PM
# Created by: Clint Jones
# Organization: Virtually Genius!
# Filename: StorageVMotion-BulkVMs
#========================================================================
#Import Plugins and Connect t... |
PowerShellCorpus/PoshCode/e7cd2cb0-d32a-4631-a081-302f0685887c.ps1 | e7cd2cb0-d32a-4631-a081-302f0685887c.ps1 | $Mailboxes = Get-CASMailbox -Filter {HasActivesyncDevicePartnership -eq $true}
$EASMailboxes = $Mailboxes | Select-Object PrimarySmtpAddress,@{N='DeviceID';E={Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity | Select-Object –ExpandProperty DeviceID}}
$EASMailboxes | foreach {Set-CASMailbox $_.PrimarySmtpAddres... |
PowerShellCorpus/PoshCode/ConvertFrom-Hashtable 2.ps1 | ConvertFrom-Hashtable 2.ps1 | #function ConvertFrom-Hashtable {
[CmdletBinding()]
PARAM(
[Parameter(ValueFromPipeline=$true, Mandatory=$true)]
[HashTable]$hashtable
,
[switch]$Combine
,
[switch]$Recurse
)
BEGIN {
$output = @()
}
PROCESS {
if($recurse) {
$keys = $hashta... |
PowerShellCorpus/PoshCode/CommandTranscript_1.ps1 | CommandTranscript_1.ps1 | if(!$global:CommandTranscriptPrompt) {
## Record the original prompt so we can put it back if they change their minds...
$global:CommandTranscriptPrompt = ${Function:Prompt}
}
function Test-CommandTranscript {
#.Synopsis
# Tests whether or not a current command transcript is in place.
return $global:Com... |
PowerShellCorpus/PoshCode/Test-Transcribing_1.ps1 | Test-Transcribing_1.ps1 | #requires -version 2.0
function Test-Transcribing {
$externalHost = $host.gettype().getproperty("ExternalHost",
[reflection.bindingflags]"NonPublic,Instance").getvalue($host, @())
try {
$externalHost.gettype().getproperty("IsTranscribing",
[reflection.bindingflags]"NonPublic,Instance").getvalue($ex... |
PowerShellCorpus/PoshCode/Async Sockets.ps1 | Async Sockets.ps1 | if (-not ("CallbackEventBridge" -as [type])) {
Add-Type @"
using System;
public sealed class CallbackEventBridge
{
public event AsyncCallback CallbackComplete = delegate { };
private CallbackEventBridge() {}
private void CallbackInternal(IAsyncResult... |
PowerShellCorpus/PoshCode/Export-SPListToSQL.ps1 | Export-SPListToSQL.ps1 | #Change these settings as needed
#MS Access 2007 Data Components required
$connString = 'Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=2;RetrieveIds=Yes; DATABASE=http://sharepoint.acme.com/;LIST={96801432-2d03-42b8-82b0-ac96ca9fea8a};'
#See http://chadwickmiller.spaces.live.com/blog/cns!EA42395138308430!275.entry for ... |
PowerShellCorpus/PoshCode/Send-HTMLFormattedEmail_8.ps1 | Send-HTMLFormattedEmail_8.ps1 | #-------------------------------------------------
# Send-HTMLFormattedEmail
#-------------------------------------------------
# Usage: Used to send an HTML Formatted Email that is based on an XSLT template.
#-------------------------------------------------
function Send-HTMLFormattedEmail{
param ( [string]... |
PowerShellCorpus/PoshCode/Atlassian Jira Interface.ps1 | Atlassian Jira Interface.ps1 | # jirafunctions.ps1
#
# Note: Some functions are incomplete/untested. Be sure to TEST before placing in production!!
#
# Dot-source this script to connect to jira and initialize the functions.
# Ex: PS C:\\scripts\\jira> . .\\jirafunctions.ps1
# Ex: PS C:\\scripts\\jira> get-JiraReport
#
# Connects to Jira and ... |
PowerShellCorpus/PoshCode/Compile-Help_2.ps1 | Compile-Help_2.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.
#
# Minor tweak by John Robbins to work on x64 when lo... |
PowerShellCorpus/PoshCode/Get-InstalledProgram.ps1 | Get-InstalledProgram.ps1 | function Get-InstalledProgram()
{
param (
[String[]]$Computer,
$User
)
#############################################################################################
if ($User -is [String]) {
$Connection = Get-Credential -Credential $User
}
#####################################################################... |
PowerShellCorpus/PoshCode/VMtoolsUpgrade.ps1 | VMtoolsUpgrade.ps1 | #####################################################################
#
# Purpose: "Check and upgrade Tools during power cycling"
# Author: David Chung
# Support: IT Infrastructure
# Docs: N/A
#
# Instruction: 1. Create CSV file with list of servers
# 2. Execute script from PowerCLI
# 3. E... |
PowerShellCorpus/PoshCode/Short PS Prompt.ps1 | Short PS Prompt.ps1 | <#
.Synopsis
Dynamically shortens the prompt based upon window size
.Notes
I got really annoyed by having my PowerShell prompt extend across 2/3 of my window when in a deeply-nested directory structure.
This shortens the prompt to roughly 1/3 of the window width, at a minimum showing the first and last piece of... |
PowerShellCorpus/PoshCode/d657a0f0-47e1-4233-9e3b-cffc0495188f.ps1 | d657a0f0-47e1-4233-9e3b-cffc0495188f.ps1 |
function Start-ISE ()
{
<#
.synopsis
Load some file into ISE
.Description
Load some file into ISE
.Parameter fileObjOrFileName
file to be loaded
.ReturnValue
$null
.Notes
Author: bernd kriszio
e-mail: bkriszio@googlemail.com
... |
PowerShellCorpus/PoshCode/Reflection Module 4.1.ps1 | Reflection Module 4.1.ps1 | #requires -version 2.0
# ALSO REQUIRES Autoload for some functionality (Latest version: http://poshcode.org/3173)
# You should create a Reflection.psd1 with the contents:
# @{ ModuleToProcess="Reflection.psm1"; RequiredModules = @("Autoload"); GUID="64b5f609-970f-4e65-b02f-93ccf3e60cbb"; ModuleVersion="4.1.0.0" ... |
PowerShellCorpus/PoshCode/WriteFileName.ps1 | WriteFileName.ps1 | # functions to print overwriting multi-line messages. Test script will accept a file/filespec/dir and iterate through all files in all subdirs printing a test message + file name to demostrate.
# e.g. PS>.\\writefilename.ps1 c:\\
# call WriteFileName [string]
# after done writing series of overwriting messages, cal... |
PowerShellCorpus/PoshCode/AnalyzeScript.ps1 | AnalyzeScript.ps1 | <#
.SYNOPSIS
Analyzes script and gives starting lines & columns of script components
.DESCRIPTION
AnalyzeScript opens a dialog box for user selection; checks that input is
a powershell script; parses and agrigates the script components into the
following tokens:
Unknown(s)
Command(s)
... |
PowerShellCorpus/PoshCode/TabExpansion for V2CTP_9.ps1 | TabExpansion for V2CTP_9.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/Find Local Group Members.ps1 | Find Local Group Members.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/New-XVM_8.ps1 | New-XVM_8.ps1 | #Examples
<#
New-XVM -Name "WS2012-TestServer01" -SwitchName "Switch(192.168.2.0/24)" -VhdType NoVHD
New-XVM -Name "WS2012-TestServer02" -SwitchName "Switch(192.168.2.0/24)" -VhdType ExistingVHD -VhdPath 'D:\\vhds\\WS2012-TestServer02.vhdx'
New-XVM -Name "WS2012-TestServer03" -SwitchName "Switch(192.168.2.0/24)" ... |
PowerShellCorpus/PoshCode/Findup_7.ps1 | Findup_7.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;
namespace Findup
{
public class FileInfoExt
{
public FileInfoExt(FileInfo fi)
... |
PowerShellCorpus/PoshCode/Enable-RemotePsRemoting..ps1 | Enable-RemotePsRemoting..ps1 | ##############################################################################\n##\n## Enable-RemotePsRemoting\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/Invoke-ResetPassword.ps1 | Invoke-ResetPassword.ps1 | # From: Brandon Shell
# Purpose: To Reset Local User Account
# Example:
# -- To Reset user Password
# PS> Add-User -user Jsmith -password H!Th3r3 -server myserver1
# With Creds
# PS> Add-User -user Jsmith -password H!Th3r3 -server myserver1 -luser adminGuy -lPassword HateClearText!
... |
PowerShellCorpus/PoshCode/18072022-fd64-4e12-ae6e-d021defcfff3.ps1 | 18072022-fd64-4e12-ae6e-d021defcfff3.ps1 | # Name: zip.ps1
# Author: Shadow
# Created: 05/12/2008
param([string]$zipfilename=$(throw "ZIP archive name needed!"),
[string[]]$filetozip=$(throw "Supply the file(s) to compress (wildcards accepted)"))
trap [Exception] {break;}
#empyt zip file contents
$emptyzipfile=80,75,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0... |
PowerShellCorpus/PoshCode/AD-GroupMembers_v2.ps1 | AD-GroupMembers_v2.ps1 | function AD-GroupMembers() {
param (
$Domen,
$Group,
$User
)
if ($User){$Connection = Get-Credential -Credential $user}
if($Connection){$Member = Get-QADGroupMember -Service $Domen -Identity $Group -Credential $Connection -SizeLimit 0 -ErrorAction SilentlyContinue | Sort Name | Format-List Name,NTAccountName,Sid... |
PowerShellCorpus/PoshCode/Get-FirewallStatus2.ps1 | Get-FirewallStatus2.ps1 | filter global:get-firewallstatus2 ([string]$computer = $env:computername)
{
if ($_) { $computer = $_ }
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$computer)
$firewallEnabled = $reg.OpenSubKey("System\\ControlSet001\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\DomainProfil... |
PowerShellCorpus/PoshCode/Locked accounts alerter.ps1 | Locked accounts alerter.ps1 | #Created By: Ty Lopes
#Sept 2012
#Sript to be run by a scheduled task that monitors for a specific event ID (in this case account locked)
#The sript then reads the last correstponding event ID and emails the details
#I could only get this alert to work properly by using this method... There may be something easier/... |
PowerShellCorpus/PoshCode/Get-ImageMetaData_1.ps1 | Get-ImageMetaData_1.ps1 | function Get-ImageMetadata {
#.Synopsis
# pull EXIF, XMP, and other data from images using the BitmapMetaData
#.Example
# $image = Get-ImageMetadata C:\\Users\\JBennett\\Pictures\\3200x1200\\02179_piertonowhere_interfacelift_com.jpg -verbose
# $image | fl *tiff*
# $image | fl *exif*
## Usage: ls *.jpg | Get... |
PowerShellCorpus/PoshCode/Set-defaultBrowser.ps1 | Set-defaultBrowser.ps1 | function Set-defaultBrowser
{
param($defaultBrowser)
switch ($defaultBrowser)
{
'IE' {
Set-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\ftp\\UserChoice' -name ProgId IE.FTP
Set-ItemProperty 'HKCU:\\Software\\Microsoft\\Wind... |
PowerShellCorpus/PoshCode/Autoload (beta 3).ps1 | Autoload (beta 3).ps1 | #Requires -Version 2.0
## Version History
## beta 3 - 2010.05.10
## fix for signed scripts (strip signature)
## beta 2 - 2010.05.09
## implement module support
## beta 1 - 2010.04.14
## Initial Release
## Automatically load functions from scripts on-demand, instead of having to ... |
PowerShellCorpus/PoshCode/Get-FreeRAM.ps1 | Get-FreeRAM.ps1 | function Get-FreeRam {
#.Synopsis
# Gets the FreePhysicalMemory from the specified computer(s)
#.Parameter ComputerName
# The name(s) of the computer(s) to get the Free Ram (FreePhysicalMemory) for.
#.Example
# Get-FreeRam SDI-JBennett, Localhost
#
# Computer FreePhysicalMemory
# -------- ... |
PowerShellCorpus/PoshCode/Migrate-ADMTUser_1.ps1 | Migrate-ADMTUser_1.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-Cpl.ps1 | Get-Cpl.ps1 | function Get-Cpl {
dir $env:windir\\system32 | Where-Object {$_.Extension -eq ".cpl"} | Select-Object Name,@{Name="Description";Expression={$_.VersionInfo.FileDescription}} | Sort-Object Description | Format-Table -AutoSize
}
|
PowerShellCorpus/PoshCode/Chassis Type_1.ps1 | Chassis Type_1.ps1 | $system = Get-WMIObject -class Win32_systemenclosure
$type = $system.chassistypes
Switch ($Type)
{
"1" {"Chassis type is: $Type - Other"}
"2" {"Chassis type is: $type - Virtual Machine"}
"3" {"Chassis type is: $type - Desktop"}
"4" {"Chassis type is: $type - Low Profile Desk... |
PowerShellCorpus/PoshCode/FTP upload.ps1 | FTP upload.ps1 | $File = "D:\\Dev\\somefilename.zip"
$ftp = "ftp://username:password@example.com/pub/incoming/somefilename.zip"
"ftp url: $ftp"
$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)
"Uploading $File..."
$webclient.UploadFile($Uri, $File)
|
PowerShellCorpus/PoshCode/Compare-PathAcl.ps1 | Compare-PathAcl.ps1 | [CmdletBinding()]
param(
[string]$Path = 'C:\\',
[string]$User1 = "$Env:USERDOMAIN\\$Env:UserName",
[string]$User2 = "BuiltIn\\Administrators",
[switch]$recurse
)
foreach($fso in ls $path -recurse:$recurse) {
$acl = @(get-acl $fso.FullName | select -expand Access | Where IdentityReference -in $user1,$user... |
PowerShellCorpus/PoshCode/Remove-AeroPeek.ps1 | Remove-AeroPeek.ps1 | function Remove-AeroPeek {
PARAM(
[string]$Title="*",
[string]$Process="*"
)
BEGIN {
try {
$null = [Huddled.DWM]
} catch {
Add-Type -Type @"
using System;
using System.Runtime.InteropServices;
namespace Huddled {
public static class Dwm {
[DllImport("dwmapi.dll", PreserveSig = false... |
PowerShellCorpus/PoshCode/Out-CliXml.ps1 | Out-CliXml.ps1 | function Out-CliXml
{
<#
.SYNOPSIS
Creates an XML-based representation of an object or objects and outputs it as a string.
.DESCRIPTION
The Out-Clixml cmdlet creates an XML-based representation of an object or objects and outputs it as a string. This cmdlet is similar to Export-CliXml except it doesn't output t... |
PowerShellCorpus/PoshCode/f19ac581-ba99-480c-a4ec-92f9084f0d26.ps1 | f19ac581-ba99-480c-a4ec-92f9084f0d26.ps1 | Function Get-EmptyGroup
{
<#
.Synopsis
Retrieves all groups without members in a domain or container.
.Description
Retrieves all groups without members in a domain or container.
.Notes
Name : Get-EmptyGroup
Author : Oliver Lipkau <oliv... |
PowerShellCorpus/PoshCode/New-ADSubnet.ps1 | New-ADSubnet.ps1 |
param ($Subnet, $SiteName, $Location, [switch]$Help)
function Help
{
""
Write-Host "Usage: .\\New-ADSubnet.ps1 -Help" -foregroundcolor Yellow
Write-Host "Usage: .\\New-ADSubnet.ps1 <Subnet> <SiteName> <Location>" -foregroundcolor Yellow
Write-Host "Ex: .\\New-ADSubnet.ps1 10.150.0.0/16 Default-First-Site-Name... |
PowerShellCorpus/PoshCode/PROMPT_ Battery life.ps1 | PROMPT_ Battery life.ps1 | # ==============================================================================================
#
# Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2007
#
# NAME: Battery-Prompt.ps1
#
# AUTHOR: Jeremy D. Pavleck , Pavleck.NET
# DATE : 12/18/2008
#
# COMMENT: Lists the pe... |
PowerShellCorpus/PoshCode/Create-Printers_1.ps1 | Create-Printers_1.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/Log Lost Pings.ps1 | Log Lost Pings.ps1 | # Logpings.ps1
# Version: 1.0
# Author: Jacob Saaby Nielsen
# Author E-Mail: jsy@systematic.com
# Purpose: Repeatedly ping a host, document lost pings to a logfile
# Syntax: .\\Logpings hostname interval (where interval is a value representing seconds)
# Requirements: /n Software's NetCmdlets http://www.nsoftware... |
PowerShellCorpus/PoshCode/Import-Certificate_7.ps1 | Import-Certificate_7.ps1 | #requires -Version 2.0
function Import-Certificate
{
param
(
[IO.FileInfo] $CertFile = $(throw "Paramerter -CertFile [System.IO.FileInfo] is required."),
[string[]] $StoreNames = $(throw "Paramerter -StoreNames [System.String] is required."),
[switch] $LocalMachine,
[switch] $CurrentUser,
[string... |
PowerShellCorpus/PoshCode/Get-User_7.ps1 | Get-User_7.ps1 | function Get-User($user)
{
# this function should be passed the CN of the user to be returned
$dom = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$root = [ADSI] "LDAP://$($dom.Name)"
$searcher = New-Object System.DirectoryServices.DirectorySearcher $root
$searcher.filter = "(&(objec... |
PowerShellCorpus/PoshCode/new get-parameter script.ps1 | new get-parameter script.ps1 | param (
$Cmdlet,
[switch]$ShowCommon,
[switch]$Full
)
$command = Get-Command $Cmdlet -ea silentlycontinue
# resolve aliases (an alias can point to another alias)
while ($command.CommandType -eq "Alias") {
$command = Get-Command ($command.definition)
}
if (-not $command) { return }
foreach ($... |
PowerShellCorpus/PoshCode/f316d247-86b3-4eee-b61f-313e456fe5d5.ps1 | f316d247-86b3-4eee-b61f-313e456fe5d5.ps1 | # This is to remove the Hidden folder attribute and delete the autorun.inf and x.mpeg due to changeup virus!
# 4-3-2013 John R Remillard
# You need the exact root folder path to unhide and delete the proper files and folders.
#$Pth = Read-Host "Enter full path to unhide"
$Lst = Get-Content c:\\Shares.txt
foreach (... |
PowerShellCorpus/PoshCode/Get-HardlinkInfo.ps1 | Get-HardlinkInfo.ps1 | # .SYNOPSIS
# Returns information about NTFS hard links. Only available on Windows Vista or later.
#
# .DESCRIPTION
# This script can be used to determine how many alternate file names (i.e. hard link
# siblings) a particular file has or to return all hard link siblings as FileInfo
# objects. It uses the Wi... |
PowerShellCorpus/PoshCode/Out-Html_1.ps1 | Out-Html_1.ps1 | ################################################################################
# Out-HTML - converts module functions or cmdlet help to HTML format
# Minor modification of Vegard Hamar's OUT-HTML to support modules instead of pssnapin's
# Based on Out-wiki by Dimitry Sotnikov (http://dmitrysotnikov.wordpress.com/2... |
PowerShellCorpus/PoshCode/Get-PrivateProfileString.ps1 | Get-PrivateProfileString.ps1 | #############################################################################\n##\n## Get-PrivateProfileString\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/Get-UNCPath.ps1 | Get-UNCPath.ps1 | function Get-UNCPath {param( [string]$HostName,
[string]$LocalPath)
$NewPath = $LocalPath -replace(":","$")
#delete the trailing \\, if found
if ($NewPath.EndsWith("\\")) {
$NewPath = [Text.RegularExpressions.Regex]::Replace($NewPath, "\\\\$", "")
}
"\\\\$HostName\\$NewPath"
}
|
PowerShellCorpus/PoshCode/Import-Certificate_6.ps1 | Import-Certificate_6.ps1 | #requires -Version 2.0
function Import-Certificate
{
param
(
[IO.FileInfo] $CertFile = $(throw "Paramerter -CertFile [System.IO.FileInfo] is required."),
[string[]] $StoreNames = $(throw "Paramerter -StoreNames [System.String] is required."),
[switch] $LocalMachine,
[switch] $CurrentUser,
[string... |
PowerShellCorpus/PoshCode/Get-SpecialPath.ps1 | Get-SpecialPath.ps1 | ###############################################################################
## Get-SpecialPath Function (should be an external function in your profile, really)
## This is an enhancement of [Environment]::GetFolderPath($folder) to add
## support for 8 additional folders, including QuickLaunch, and the commo... |
PowerShellCorpus/PoshCode/PowerCLI error report.ps1 | PowerCLI error report.ps1 | $moveVmScript = {
Connect-VIServer yourVCenterServer
Move-VM WinXP -Location yourDestinationHost
}
$ moveVmScript | Get-ErrorReport -ProblemScriptTimeoutSeconds 120 -ProblemDescription "An error is returned by Move-VM. The operation should be successful. The same can be done via the vClient." -Destination 'D:\\b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.