full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Receive-Stream.ps1
Receive-Stream.ps1
function Receive-Stream { #.Synopsis # Read a stream to the end and close it #.Description # Will read from a byte stream and output a string or a file #.Param reader # The stream to read from #.Param fileName # A file to write to. If this parameter is provided, the function will output to file #.Param enc...
PowerShellCorpus/PoshCode/Get_Set Signature 2.5.ps1
Get_Set Signature 2.5.ps1
#Requires -version 2.0 ## Authenticode.psm1 updated for PowerShell 2.0 (with time stamping) #################################################################################################### ## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets ## These properly parse paths, so th...
PowerShellCorpus/PoshCode/Dell hardware checker.ps1
Dell hardware checker.ps1
function load-omsa([string]$server) { $omsaie = new-object -com InternetExplorer.Application if (($server -eq $null) -or ($server -eq "")) { write-host -foregroundcolor "yellow" "Usage: omsa servername" write-host -foregroundcolor "yellow" " Enter servername to open OMSA connection to server" write...
PowerShellCorpus/PoshCode/Search-NetworkService_1.ps1
Search-NetworkService_1.ps1
#Define PreReqs $timeStamp = Get-Date -UFormat "%m-%d-%Y-%H-%M" $systemVars = Gwmi Win32_ComputerSystem -Comp "." $userName = $systemVars.UserName $compName = $systemVars.Name #User Vars $serviceName = "Spooler" # Spooler will check the Print Spooler <<< Change To Suit Your needs $errorLog = "C:\\Temp\\Log_"+$...
PowerShellCorpus/PoshCode/script does not continue.ps1
script does not continue.ps1
Process { # If the computer isn't pingable, move on to next in pipeline. @@ if ( -not ( SelectAlive $_ ) ) { continue }
PowerShellCorpus/PoshCode/Get-LeaderBoard_1.ps1
Get-LeaderBoard_1.ps1
<# .SYNOPSIS Pulls down the leaderboards for the 2011 Scripting Games .DESCRIPTION Quick and dirty script to pull down the leaderboards for the 2011 scripting games. Can choose either beginner or advanced via a command line switch. .PARAMETER Level The leaderboard to parse .EXAMPLE Get...
PowerShellCorpus/PoshCode/Get-User_10.ps1
Get-User_10.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/Reset-Tray_1.ps1
Reset-Tray_1.ps1
function Reset-Tray { Add-Type -Assembly UIAutomationClient $Window = Add-Type -Name ([char[]](65..90 | Get-Random -count 10) -join "") -Member @" [DllImport("user32")] public static extern IntPtr PostMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam); public static void SendMouseMove(...
PowerShellCorpus/PoshCode/Set-ToStringMethod.ps1
Set-ToStringMethod.ps1
function Set-ToStringMethod { <# .Synopsis Overwrites default .ToString() method of a given type. .Description Some commands use .ToString() method of an object to produce output. Default (inherited from System.Object) result of that method is object's type FullName. Tha...
PowerShellCorpus/PoshCode/vibackup-lx1.ps1
vibackup-lx1.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/Export-PSCredential_5.ps1
Export-PSCredential_5.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/Invoke-ElevatedCommand_1.p.ps1
Invoke-ElevatedCommand_1.p.ps1
param ( ## The script block to invoke elevated [Parameter(Mandatory = $true)] [ScriptBlock] $Scriptblock, ## Any input to give the elevated process [Parameter(ValueFromPipeline = $true)] $InputObject, ## Switch to enable the user profile [switch] $EnableProfile ) begi...
PowerShellCorpus/PoshCode/New-Event.ps1
New-Event.ps1
#.Synopsis # Parse natural language descriptions of appointments or meetings ... #.EXAMPLE @@# New-Event Lunch every other Friday at 11:45 @@# @@# day_of_week interval start_date start_time type message @@# ----------- -------- ---------- ---------- ---- ------- @@# fri 2 20100122 11:...
PowerShellCorpus/PoshCode/Update-DeptGPOs_1.ps1
Update-DeptGPOs_1.ps1
<# .SYNOPSIS Update permissions on Departmental GPO's .DESCRIPTION This script will backup all existing GPO's in the domain prior to making any changes. After the backup has been made Departmental GPOs will be updated based on their Dept Code. .PARAMETER DeptCode A cod...
PowerShellCorpus/PoshCode/SQL Query - AD Pwd Reset.ps1
SQL Query - AD Pwd Reset.ps1
<# .SYNOPSIS Author:......Vidrine Date:........2012/04/08 .DESCRIPTION Script connects to a SQL database and runs a query against the specified table. Depending on table record values, an Active Directory user object will have it's password reset. Once, the account is reset the SQL record is updated. ...
PowerShellCorpus/PoshCode/BufferBox 3.0.ps1
BufferBox 3.0.ps1
#################################################################################################### ## This script is just a demonstration of some of the things you can do with the buffer ## in the default PowerShell host... it serves as a reminder of how much work remains on ## PoshConsole, and as an inspirations ...
PowerShellCorpus/PoshCode/Set-Computername.ps1
Set-Computername.ps1
function Set-ComputerName { param( [switch]$help, [string]$computerName=$(read-host "Please specify the new name of the computer")) $usage = "set-ComputerName -computername AnewName" if ($help) {Write-Host $usage} $computer = Get-WmiObject Win32_ComputerSystem $computer.Rename($computerName) }
PowerShellCorpus/PoshCode/Fifteen.ps1
Fifteen.ps1
Imports System Imports System.Drawing Imports System.Reflection Imports System.Globalization Imports System.Windows.Forms <assembly: AssemblyDescription("Fifteen")> <assembly: AssemblyProduct("fifteen.exe")> <assembly: AssemblyTitle("Fifteen")> <assembly: AssemblyVersion("2.0.0.0")> <assembly: CLSCompliant(T...
PowerShellCorpus/PoshCode/Get-ObjectIdentifier.ps1
Get-ObjectIdentifier.ps1
##################################################################### # Get-ObjectIdentifier.ps1 # Version 1.0 # # Resolves OID value to a Friendly Name and vice versa. # # Vadims Podans (c) 2010 # http://en-us.sysadmins.lv/ ##################################################################### #requires -Versi...
PowerShellCorpus/PoshCode/Get-SameTimeChatHistory.ps1
Get-SameTimeChatHistory.ps1
# TITLE: Get-SameTimeChatHistory.ps1 # PURPOSE: Reads Sametime R8 chat transcript HTML files and outputs custom objects # AUTHOR: Hal Rottenberg <hal@halr9000.com # OUTPUT: # - [datetime] Timestamp - can be easily filtered # - [string] LastName # - [string] FirstName # - [string] Message # # REQUIREMENTS: ...
PowerShellCorpus/PoshCode/IniFile Functions 1.1.ps1
IniFile Functions 1.1.ps1
function Get-IniSection($inifile,$section) { $sections = select-string "^\\[.*\\]" $inifile if(!$section) { return $sections | %{$_.Line.Trim("[]")} } $start = 0 switch($sections){ {$_.Line.Trim() -eq "[$section]"}{ $start = $_.LineNumber -1 } defaul...
PowerShellCorpus/PoshCode/Enable_Disable NIC, XP+.ps1
Enable_Disable NIC, XP+.ps1
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # Name: ifstate # Author: Kris Cieslak (defaultset.blogspot.com) # Date: 2010-04-21 # Description: Enabling/Disabling network adapter. # Works on Windows XP and higher. # ...
PowerShellCorpus/PoshCode/ActiveDirectoryFunctions.ps1
ActiveDirectoryFunctions.ps1
#.SYNOPSIS # Gets a directory entry from ActiveDirectory based on the login user name function Get-ADUser { [CmdletBinding()] param([string]$UserName=${Env:userName}) $ads = New-Object System.DirectoryServices.DirectorySearcher([ADSI]'') $ads.filter = "(&(objectClass=Person)(samAccountName=$UserName))" ...
PowerShellCorpus/PoshCode/Skip-Object.ps1
Skip-Object.ps1
function Skip-Object { param( [int]$First = 0 , [int]$Last = 0 , [int]$Every = 0 , [int]$UpTo = 0 ) begin { if($Last) { $Queue = new-object System.Collections.Queue $Last } $e = $every $UpTo++ # $u = $UpTo } process { $_ | where { --$First -lt 0 ...
PowerShellCorpus/PoshCode/Set account password.ps1
Set account password.ps1
Function Set-Password { #requires -version 2.0 <# .Synopsis Allows the changing of the local account password on a local or remote machine. .Description Allows the changing of the local account password on a local or remote machine. .Parameter computer Computer that the password will be changed on...
PowerShellCorpus/PoshCode/TruncatePath_1.ps1
TruncatePath_1.ps1
### # TruncatePath # Version 1.0.6 (05 Nov 2008) # Description: Replaces long provider paths in the prompt with ellipses # Notes: Place in your profile # # By Mike Hays, http://www.mike-hays.net ### $maxPathLength = 40 $showFullPath = $false Function Prompt { $currentPath = (Get-Location).Path if ( ...
PowerShellCorpus/PoshCode/get-ESXiHostConfigBackup.ps1
get-ESXiHostConfigBackup.ps1
<# .SYNOPSIS Creates config bundle backup for ESXi hosts. Works where 80 is blocked to ESXi host Originally script by Alan Renouf (http://www.virtu-al.net/2011/02/23/backing-up-the-esxi-system-image) Heavily Modified by Jimmy Hester .DESCRIPTION Checks for connection to a vCenter or ESXi server If not connected...
PowerShellCorpus/PoshCode/TruncatePath_2.ps1
TruncatePath_2.ps1
### # TruncatePath # Version 1.0.6 (05 Nov 2008) # Description: Replaces long provider paths in the prompt with ellipses # Notes: Place in your profile # # By Mike Hays, http://www.mike-hays.net ### $maxPathLength = 40 $showFullPath = $false Function Prompt { $currentPath = (Get-Location).Path ...
PowerShellCorpus/PoshCode/Findup_10.ps1
Findup_10.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/Powershell iTunes.ps1
Powershell iTunes.ps1
# #***************************************************************** # # Powershell iTunes v1 $Rev: 752 $ # (c) 2004-2010 Thomas Maurer. All rights reserved. # created by Thomas Maurer # # http://www.thomasmaurer.ch # http://www.thomasmaurer.ch/projects # # last Update by $Author: tmaurer $ on $Date: 2010-11...
PowerShellCorpus/PoshCode/MoveExch2010SP1Archives.ps1
MoveExch2010SP1Archives.ps1
#================================================================================= # MoveArchives.ps1 # # THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY # KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A # PART...
PowerShellCorpus/PoshCode/Search cmdlet help_1.ps1
Search cmdlet help_1.ps1
function Search-Help($term) { Get-Command | Where { Get-Help -full -ea SilentlyContinue $_ | Out-String | Select-String $term } }
PowerShellCorpus/PoshCode/dc580007-f61d-477a-a409-395481ffb01a.ps1
dc580007-f61d-477a-a409-395481ffb01a.ps1
CREATE LOGIN [vCenter_Owner] WITH PASSWORD=N'KVx$!|mhQ^', CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF GO --Modify Drive and size to match your environment CREATE DATABASE [vCenter] ON PRIMARY ( NAME = N'vCenter', FILENAME = N'S:\\Data\\vCenter.mdf' , SIZE = 100MB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%) LOG ON (...
PowerShellCorpus/PoshCode/FTP upload_2.ps1
FTP upload_2.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/Get-WmiNamespace.ps1
Get-WmiNamespace.ps1
# In order to enumerate all the WMI namespaces, you must first connect to the "root" namespace, # query for all the "__NAMESPACE" instances, and for each instance recursively repeat this process. # You can use the computerName parameter of Get-WmiNamespace to list the WMI namespaces on the remote computer. functio...
PowerShellCorpus/PoshCode/Delete Files per folder.ps1
Delete Files per folder.ps1
<# .SYNOPSIS Deletes files in directory based on age measured in days .DESCRIPTION Delete files in folder with use of regular filter, either recursive or not. .PARAMETER DelFilter Provide a filter like "*.txt" or "mylogs*" .PARAMETER DelPath The directory where files are to be deleted from, use the Rec...
PowerShellCorpus/PoshCode/Out-Posh.ps1
Out-Posh.ps1
# Personally, I use this as a script (just save in your path as Out-Posh.ps1, and delete all but the middle line (that starts with "end") function out-posh { end { New-BootsWindow { $input } -inline } }
PowerShellCorpus/PoshCode/Reset Time Sync Setting.ps1
Reset Time Sync Setting.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/Calculate HA Capaicty.ps1
Calculate HA Capaicty.ps1
### Written by Mark A. Weaver ## Date: 7/27/2008 ## Version: 1.0 ## Blog site: blog.vmweaver.com ## ## Call this function and pass in -ServerName <VC Server Name> -ClusterName <ClusterName> ## Output should be an object containing the information ## ## Feel free to modify as needed to suit your needs, but...
PowerShellCorpus/PoshCode/ServicePWChgReset_1.ps1
ServicePWChgReset_1.ps1
# ============================================================================================== # # NAME: ServicePWChgReset.ps1 # # AUTHOR: Saehrig, Steven # DATE : 8/26/2008 @@# Requires - Quest ActiveRoles Snapin @@# COMMENT: Please read comments on each section! # 1st - Search Domain computers for matc...
PowerShellCorpus/PoshCode/WIMM Emulator Launcher.ps1
WIMM Emulator Launcher.ps1
## ## Start-WimmEmulator.ps1 ## ## Starts the WIMM emulator - must be placed in the add-ons\\addon_wimm_one_7\\tools ## directory along with the rest of the WIMM tools. ## ## http://dev.wimm.com/ if(-not $env:ANDROID_SDK_DIR) { $env:ANDROID_SDK_DIR = Resolve-Path (Join-Path $psscriptRoot ..\\..\\..) } ...
PowerShellCorpus/PoshCode/Test-Help.ps1
Test-Help.ps1
function Test-Help { <# .Synopsis Test-Help -Function Get-USB .Description Test-Help was written to get information why that !@##$%#$%# help is not working ;) For now works only if v2 comments are used (starting with < # and ending with # > ) Using fancy regex that pro...
PowerShellCorpus/PoshCode/Get-FeedInfo.ps1
Get-FeedInfo.ps1
function Get-FeedInfo([string[]]$feeds) { # $feeds is an array of rss/atom URLs $blogs=@(); $broken=@(); $feeds = $feeds | sort -unique {$_} foreach($feed in $feeds){ try { $xml = Get-WebPageContent $feed; } catch { $broken += $feed $xml = $null } if($xml.html.rss) { $xml = $...
PowerShellCorpus/PoshCode/New-XML 2.ps1
New-XML 2.ps1
#requires -version 2.0 #### NOTE: you can revert this to work in PowerShell 1.0 by just removing the [Parameter(...)] lines #### BUT YOU WILL HAVE TO pass the $Version $Encoding $Standalone parameters EACH TIME #### UNLESS you remove them, and switch back to a hardcoded XDeclaration ... or something. ##...
PowerShellCorpus/PoshCode/Impersonation.ps1
Impersonation.ps1
$global:ImpContextStack = new-object System.Collections.Generic.Stack[System.Security.Principal.WindowsImpersonationContext]\n$global:IdStack = new-object System.Collections.Generic.Stack[System.Security.Principal.WindowsIdentity]\n\n\n$global:UserToysClass = Add-Type -Namespace Huddled -Name UserToys -MemberDefinition...
PowerShellCorpus/PoshCode/11a7b312-21b4-4faa-8224-35bea9db7f89.ps1
11a7b312-21b4-4faa-8224-35bea9db7f89.ps1
param( [Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)] [alias("Name","ComputerName")] $Computer = @($env:computername), [string] $NTDomain = ($env:UserDomain), [string[]] $LocalGroups = @("Administrators"), [string[]] $Identities, # can be domain user or group [switch] $Outpu...
PowerShellCorpus/PoshCode/73cbcdc1-9397-4ed2-99e3-b043b8c53905.ps1
73cbcdc1-9397-4ed2-99e3-b043b8c53905.ps1
# 1. Create a simple customizations spec: $custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows -OrgName “My Organization” -FullName “MyVM” -Domain “MyDomain” –DomainAdminUsername “user” –DomainAdminPassword “password” # 2. Modify the default network customization settings: $custSpec | Get-OSCustom...
PowerShellCorpus/PoshCode/Get-StrictMode.psm1.ps1
Get-StrictMode.psm1.ps1
<# .SYNOPSIS A very simple module to retrieve the Set-StrictMode setting of the session. .DESCRIPTION This procedure is necessary as there is, apparently, no PowerShell variable for this and enables the user setting to be returned to its original state after possibly being changed within a script. The various...
PowerShellCorpus/PoshCode/Validate SPN Mappings.ps1
Validate SPN Mappings.ps1
###########################################################################" # # NAME: SPNValidation.psm1 # # AUTHOR: Jan Egil Ring # BLOG: http://blog.crayon.no/blogs/janegil # # COMMENT: Script module for validating SPN mappings. # For installation instructions and sample usage, see the following blo...
PowerShellCorpus/PoshCode/ModuleWriteError.psd1.ps1
ModuleWriteError.psd1.ps1
# # Module manifest for module 'ModuleWriteError' # # Generated by: Thell Fowler # # Generated on: 1/13/2010 # @{ # Script module or binary module file associated with this manifest ModuleToProcess = 'ModuleWriteError.psm1' # Version number of this module. ModuleVersion = '1.0' # ID used to uniquely...
PowerShellCorpus/PoshCode/IE Proxy Toggle (Silent).ps1
IE Proxy Toggle (Silent).ps1
# Process command line parameter (if present). [bool] $DISABLE_PROXY = $false; foreach ($param in $MyInvocation.UnboundArguments) { if ($param -like 'disable') { $DISABLE_PROXY = $true; } } # Apply/refresh the organization's default proxy settings. @@ [string] $proxyServer = '###.###.###.###:####'; ...
PowerShellCorpus/PoshCode/Sith.ps1
Sith.ps1
' Script: Master_Audit_AD_Account_Management - 2008 v4 S1S2.vbs (Version 4 Section1 and Section2 combi script) ' Purpose: Parse a DC's security event log and generate account management events, log and e-mail for past 24hs ' Author: Paperclips (The Dark Lord) ' Email: magiconion_M@hotmail.com ' Date: ...
PowerShellCorpus/PoshCode/Script for mBull.ps1
Script for mBull.ps1
$endDate = New-Object datetime(2013,1, 1) for ($date = [DateTime]::Today; $date -le $endDate; $date = $date.AddDays(1);) { if ($date.DayOfWeek -ne [DayOfWeek]::Saturday -and $date.DayOfWeek -ne [DayOfWeek]::Saturday) { New-Item -type directory $date.ToShortDateString() } }
PowerShellCorpus/PoshCode/d599ff7e-17c4-40a4-b3fc-8666dd953df5.ps1
d599ff7e-17c4-40a4-b3fc-8666dd953df5.ps1
function Get-VCTime() { return (Get-View "ServiceInstance-ServiceInstance").CurrentTime() } $lastCheckTime = Get-VCTime while ($true) { $modifiedVMs = @() $freshEventsStartTime = $lastCheckTime $lastCheckTime = Get-VCTime # Get all the VM network edit events foreach ($event in Get...
PowerShellCorpus/PoshCode/Reverse filename sequenc_2.ps1
Reverse filename sequenc_2.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/mGet-DatastoreList.ps1
mGet-DatastoreList.ps1
Function mGet-DatastoreList { #Parameter- Name of the VMware cluster to choose a datastore from. param($Cluster) #get alphabetically last ESX host in the VMware cluster (it's likely the last host added to the cluster, so this might smoke out any problems) $VMH = get-vmhost -Location $cluster | Where-Object { ($_....
PowerShellCorpus/PoshCode/VMtoolsUpgrade-disable.ps1
VMtoolsUpgrade-disable.ps1
##################################################################### # TIAA-CREF VMWare Standard Scripts - PowerCLI # # 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 # ...
PowerShellCorpus/PoshCode/Test-UserCredential.ps1
Test-UserCredential.ps1
function Test-UserCredential { [CmdletBinding()] [OutputType([System.Boolean])] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Username, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System.String] $Password, [Parameter()] [Switch] $Domain ) ...
PowerShellCorpus/PoshCode/ImaginaryFriendFeed_1.ps1
ImaginaryFriendFeed_1.ps1
#.SYNOPSIS # A few functions for working with FriendFeed and Twitter #.DESCRIPTION # Allows you to copy your users from Twitter to imaginary FriendFeed users... #.EXAMPLE # ## Get any twitter friends who aren't on friendfeed # ## Make sure you use FriendFeed's built in "add all your twitter friends" first # $t...
PowerShellCorpus/PoshCode/Ping-Host.ps1
Ping-Host.ps1
function Ping-Host {param( [string]$HostName, [int32]$Requests = 3) for ($i = 1; $i -le $Requests; $i++) { $Result = Get-WmiObject -Class Win32_PingStatus -ComputerName . -Filter "Address='$HostName'" Start-Sleep -Seconds 1 if ($Result.StatusCode -ne 0) {return $FALSE} } return $TRUE }
PowerShellCorpus/PoshCode/DriveSpace.format.ps1xml.ps1
DriveSpace.format.ps1xml.ps1
<?xml version="1.0" encoding="utf-8" ?> <Configuration> <Controls> <Control> <Name>DriveSpaceChart</Name> <CustomControl> <CustomEntries> <CustomEntry> <CustomItem> <Frame> <CustomItem> ...
PowerShellCorpus/PoshCode/Get-CryptoBytes.ps1
Get-CryptoBytes.ps1
function Get-CryptoBytes { #.Synopsis # Generate Cryptographically Random Bytes #.Description # Uses RNGCryptoServiceProvider to generate arrays of random bytes #.Parameter Count # How many bytes to generate #.Parameter AsString # Output hex-formatted strings instead of byte arrays param( [Parameter(Va...
PowerShellCorpus/PoshCode/DataStoreBalancer.ps1
DataStoreBalancer.ps1
#====================================================================================== # File Name : DataStoreBalancer.ps1 # Original Author : Kenneth C. Mazie # Description : Scans VM datastores and moves a single VM from the most heavily # : loaded to the...
PowerShellCorpus/PoshCode/AD_bulk_new_OU_1.ps1
AD_bulk_new_OU_1.ps1
param( $searchBase = "OU=Organisation,DC=uza,DC=local", $NewOUs = @(Import-csv -Path "d:\\projects\\AD\\departments.csv" -Delimiter ";"), $SubOUs = @("Computers","Users"), [switch]$ProtectOU ) $Protect = $false If ($ProtectOU){$Protect = $true} foreach ($NewOU in $NewOUs){ New-ADOrganizationalUnit -Name $New...
PowerShellCorpus/PoshCode/ConvertTo-ASCII.ps1
ConvertTo-ASCII.ps1
#requires –version 2.0 #region Help <# .SYNOPSIS Automation script for file character set format convertion to ASCII encoding. .DESCRIPTION Script for automating the convertion of files to ASCII format. Good for if you've used Out-File without specifying the encoding. Which would make a Unicode formatted...
PowerShellCorpus/PoshCode/Start-Process.ps1
Start-Process.ps1
function Start($app,$param) { if($param) { [Diagnostics.Process]::Start( $app, $param ) } else { [Diagnostics.Process]::Start( $app ) } }
PowerShellCorpus/PoshCode/Script-Object_2.ps1
Script-Object_2.ps1
#Copyright (c) 2011 Justin Dearing # #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, modify, merge, publish, dist...
PowerShellCorpus/PoshCode/Open-ISEFile.ps1
Open-ISEFile.ps1
#Requires -Version 2.0 function Open-ISEFile { <# .NOTES Name: Open-ISEFile Author: Tome Tanasovski Created: 6/20/2010 Version: 1.0 .SYNOPSIS Open a new file in ISE .DESCRIPTION This cmdlet allows you to open a file in a new file tab w...
PowerShellCorpus/PoshCode/PowerShellServer Cmdlet _1.ps1
PowerShellServer Cmdlet _1.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/test.ps1
test.ps1
function Write-EventDetail { param( $id ) $id | Write-Host $Event | Write-Host $EventSubscriber | Write-Host $Sender | Write-Host $SourceEventArgs | Write-Host $SourceArgs | Write-Host } 'test'
PowerShellCorpus/PoshCode/Am I a purist_.ps1
Am I a purist_.ps1
########### # PS1 script to launch gpupdate on all computers in domain, without some stupid QAD cmdlets, just pure PS1 and WMI # Made by pan_2@LJ (gunkan@yandex.ru) # Note: if by some reason RPC host was unavaible - there will be exception throwed, I didn't use trap so I can see real reason. ########### function P...
PowerShellCorpus/PoshCode/Get-Parameter 2.1.ps1
Get-Parameter 2.1.ps1
#Requires -version 2.0 #.Synopsis # Enumerates the parameters of one or more commands #.Notes # With many thanks to Hal Rottenberg, Oisin Grehan and Shay Levy # Version 0.80 - April 2008 - By Hal Rottenberg http://poshcode.org/186 # Version 0.81 - May 2008 - By Hal Rottenberg http://poshcode.org/255 # Ver...
PowerShellCorpus/PoshCode/TSRemoteApp.ps1
TSRemoteApp.ps1
function New-TSRemoteApp { <# .SYNOPSIS Creates a new RemoteApp on Windows Server 2008 Terminal Server. .DESCRIPTION Creates a new RemoteApp using the supplied parameters. .PARAMETER Alias Alias for the new RemoteApp. Accepts ValueFromPipeline and ValueFromPipelineByPropertyName. .PARAMETER Applicationpath Pat...
PowerShellCorpus/PoshCode/Format-Hex.ps1
Format-Hex.ps1
##############################################################################\n##\n## Format-Hex\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\nOutputs a fil...
PowerShellCorpus/PoshCode/SQLite Read _ Write.ps1
SQLite Read _ Write.ps1
# Make sure SQLite.Interop.dll is in the same directory as System.Data.SQLite.dll $scriptDir = "Path to your SQLite DLL" Add-Type -Path "$scriptDir\\System.Data.SQLite.dll" ############### SAMPLE USAGE ################### ### Querying: ### ### $readQuery = "SELECT * FROM TABLE" ### $dataArray = $SQLite.q...
PowerShellCorpus/PoshCode/Invoke-JQuery.ps1
Invoke-JQuery.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/Add-ExcelAddins.ps1
Add-ExcelAddins.ps1
###########################################################################" # # NAME: Add-ExcelAddins.ps1 # # AUTHOR: Jan Egil Ring # EMAIL: jan.egil.ring@powershell.no # # COMMENT: This script will check if the specified Microsoft Office Excel Addins are loaded, and if not load them. # Tested with Po...
PowerShellCorpus/PoshCode/Get-DesktopResolution.ps.ps1
Get-DesktopResolution.ps.ps1
<# .SYNOPSIS Displays Desktop Size .DESCRIPTION This script is a re-write of an MSDN sample. It uses the Win32_Desktop Monitor WMI class to obtain the screen dimensions. .NOTES File Name : Get-DesktopResolution.ps1 Author : Thomas Lee - tfl@psp.co.uk Requires : PowerShell V2 CTP3...
PowerShellCorpus/PoshCode/CertMgmt pack_4.ps1
CertMgmt pack_4.ps1
##################################################################### # CertMgmtPack.ps1 # Version 0.51 # # Digital certificate management pack # # Vadims Podans (c) 2009 # http://www.sysadmins.lv/ ##################################################################### #requires -Version 2.0 function Import-C...
PowerShellCorpus/PoshCode/connect-domain.ps1
connect-domain.ps1
function connect-domain_X { BEGIN {$foregroundcolor= (get-host).ui.rawui.get_foregroundcolor() Write-Host ""; "---------------------------------" ; "Entering Nested Prompt for Quest connection to DOMAIN_X."; "Type `"Exit`" when finished."; "---------------------------------" ; "" ...
PowerShellCorpus/PoshCode/Memory helper functions.ps1
Memory helper functions.ps1
Function Add-SessionVariable() { param ([string[]]$VariableName=$null) [string[]]$VariableNames = [AppDomain]::CurrentDomain.GetData('Variable') $VariableNames += $VariableName if ($input) { $VariableNames += $input } #To Not Waste Space, Remove Duplicates $VariableNames = $VariableNames | ...
PowerShellCorpus/PoshCode/JSON 1.4.ps1
JSON 1.4.ps1
#requires -version 2.0 # Version History: # v 0.5 - First Public version # v 1.0 - Made ConvertFrom-Json work with arbitrary JSON # - switched to xsl style sheets for ConvertTo-JSON # v 1.1 - Changed ConvertFrom-Json to handle single item results # v 1.2 - CodeSigned to make a fellow geek happy # v 1.3 - ...
PowerShellCorpus/PoshCode/Bootstrap psake w_ PsGet.ps1
Bootstrap psake w_ PsGet.ps1
function Get-MyModule { param ([string] $name) write-host "Is '$name' already imported? " -NoNewline -ForegroundColor Cyan if (-not(Get-Module -name $name)) { write-host "No." -ForegroundColor Red write-host "Can we import '$name'? " -NoNewline if (Get-Module -ListAvailable | W...
PowerShellCorpus/PoshCode/SearchZIP.psm1 Module Fi.ps1
SearchZIP.psm1 Module Fi.ps1
function SearchZIPfiles { <# .SYNOPSIS Search for (filename) strings inside compressed ZIP or RAR files. .DESCRIPTION In any directory containing a large number of ZIP/RAR compressed Web Page files this procedure will search each individual file name for simple text strings, listing both the source RAR/ZIP fi...
PowerShellCorpus/PoshCode/Copy files _1.ps1
Copy files _1.ps1
cls <# Writer: Ritesh P. #> # Core Declaration $date = ((get-date).toString('MM-dd-yyyy')) $time = ((Get-Date).toString('HH-mm-ss')) #$what = "/COPYALL /S /B" #$options = "/R:0 /W:0 /FP" $NewDestinationPath = '\\\\'+'infra'+'\\c$\\data1\\'+$date+'-'+$time # When I add $time to create Destination f...
PowerShellCorpus/PoshCode/Set-KeepAliveTime_1.ps1
Set-KeepAliveTime_1.ps1
<# .SYNOPSIS Change the setting for TCPIP KeepAliveTime on a server or several servers. .DESCRIPTION Change the setting for TCPIP KeepAliveTime on a server or several servers. When moving mailboxes with lar...
PowerShellCorpus/PoshCode/Script-Object_1.ps1
Script-Object_1.ps1
#Copyright (c) 2011 Justin Dearing # #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, modify, merge, publish, dist...
PowerShellCorpus/PoshCode/Show-ADObject.ps1
Show-ADObject.ps1
# Author: Steven Murawski http://www.mindofroot.com # This script requires the modified Show-NetMap script (originally from Doug Finke) # Show-NodeXLMap which can be found on http://poshcode.org/733 # and the NodeXL files # These can be found at http://www.codeplex.com/NodeXL/Release/ProjectReleases.aspx?ReleaseId=...
PowerShellCorpus/PoshCode/Get-ProcessCount_1.ps1
Get-ProcessCount_1.ps1
# Get-ProcessCount uses 2 main variables, server and process name. # Process name is typically the end exe, such as "svchost.exe" # Will accept unnamed args (Get-ProcessCount servername processname) # or named args (Get-ProcessCount -Computer servername -Process processname) Function Get-ProcessCount([string]$proce...
PowerShellCorpus/PoshCode/SqlProxy_2.psm1.ps1
SqlProxy_2.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/Create-Certificate.ps1
Create-Certificate.ps1
##################################################################### # Create PowerShell cert.ps1 # Version 1.0 # # Creates self-signed signing certificate and install it to certificate store # # Note: Requires at least Windows Vista. Windows XP/Windows Server 2003 # are not supported. # # Vadims Podans (c) 2...
PowerShellCorpus/PoshCode/JSON 1.2.ps1
JSON 1.2.ps1
#requires -version 2.0 # Version History: # v 0.5 - First Public version # v 1.0 - Made ConvertFrom-Json work with arbitrary JSON # - switched to xsl style sheets for ConvertTo-JSON # v 1.1 - Changed ConvertFrom-Json to handle single item results # v 1.2 - CodeSigned to make a fellow geek happy # There i...
PowerShellCorpus/PoshCode/LetterDiamondOneliner v_2.ps1
LetterDiamondOneliner v_2.ps1
&{param([char]$c)[int]$s=65;$p=$c-$s;$r=,(' '*$p+[char]$s);$r+=@(do{"{0,$p} {1}{0}"-f([char]++$s),(' '*$f++)}until(!--$p));$r;$r[-2..-99]}Z # trimmed 130 chars w/o arg &{param([char]$c)$p=$c-($s=65);$r=,(' '*$p+[char]$s);do{$r+="{0,$p} {1}{0}"-f([char]++$s),(' '*$f++)}until(!--$p);$r;$r[-2..-99]}J
PowerShellCorpus/PoshCode/Format-TablePlus_1.ps1
Format-TablePlus_1.ps1
#requires -version 2.0 ## Format-Table with wrapping and string trimming. function Format-TablePlus() { [CmdletBinding()] param( [Switch] ${AutoSize}, [Switch] ${HideTableHeaders}, [Switch] ${Wrap}, [Parameter(Position=0)] [System.Object[]] ${Property}, [System.Object...
PowerShellCorpus/PoshCode/Beginner event 10 .ps1
Beginner event 10 .ps1
# # Summer 2009 Scripting games # Beginner Event 10 - The 1,500-Meter race # http://blogs.technet.com/heyscriptingguy/archive/2009/06/18/hey-scripting-guy-2009-scripting-games-event-10-details-beginner-and-advanced-1-500-meter-race.aspx # # ToDo: In this event, you must write a script that will count down from th...
PowerShellCorpus/PoshCode/Get-DominosOrderStatus.ps1
Get-DominosOrderStatus.ps1
# Get-DominosOrderStatus.psm1 # Author: xcud.com # # Inspired by Dana Merrick's Dominos Pizza Script # http://shakti.trincoll.edu/~dmerrick/dominos.html function Get-DominosOrderStatus($phone_number) { $url = "http://trkweb.dominos.com/orderstorage/GetTrackerData?Phone=$phone_number" [xml]$content = (n...
PowerShellCorpus/PoshCode/Set-ADUserRandomPassword_2.ps1
Set-ADUserRandomPassword_2.ps1
###########################################################################" # # NAME: Set-ADUserRandomPassword.ps1 # # AUTHOR: Jan Egil Ring # EMAIL: jan.egil.ring@powershell.no # # COMMENT: This script are used to set a random password for Active Directory users in a specified Organizational Unit. It stores th...
PowerShellCorpus/PoshCode/Get-CompPartitionTable.ps1
Get-CompPartitionTable.ps1
param($computer,$instance,$database) import-module sqlps -disablenamechecking $path = "SQLSERVER:\\SQL\\$($computer)\\$($instance)\\Databases\\$($database)\\Tables" SET-LOCATION $path get-childitem | where {$_.HasCompressedPartitions -or $_.IsPartitioned} | select @{n='ServerInstance';e={"$computer\\$instance...
PowerShellCorpus/PoshCode/Get-Credential 1.2.ps1
Get-Credential 1.2.ps1
## Get-Credential ## An improvement over the default cmdlet which has no options ... ################################################################################################### ## History ## v 1.2 Refactor ShellIds key out to a variable, and wrap lines a bit ## v 1.1 Add -Console switch and set registry v...
PowerShellCorpus/PoshCode/DNS functions.ps1
DNS functions.ps1
Param ( [Parameter(Mandatory=$true, Position=1)][string] $SourceServer, [Parameter(Mandatory=$true, Position=2)][string] $SourceZone, [Parameter(Mandatory=$true, Position=3)][string] $DestinationServer, [Parameter(Mandatory=$true, Position=4)][string] $DestinationZone, [string[]] $RRtypes = @("MicrosoftDNS_AType")...