full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Copy-File (Safely).ps1 | Copy-File (Safely).ps1 | function Copy-File {
#.Synopsis
# Copies all files and folders in $source folder to $destination folder, but with .copy inserted before the extension if the file already exists
param($source,$destination)
# create destination if it's not there ...
mkdir $destination -force -erroraction SilentlyContinue
foreac... |
PowerShellCorpus/PoshCode/Send-FTP _1.0.ps1 | Send-FTP _1.0.ps1 | function Send-FTP {
Param(
$Server = "ilncenter.net"
, $Credentials = $(Get-Credential)
, [Parameter(ValueFromPipeline=$true)]
$LocalFile
, $Path = "/"
, $RemoteFile = $(Split-Path $LocalFile -Leaf)
, $ParentProgressId = -1 ## Just ignore this ;)
... |
PowerShellCorpus/PoshCode/Invoke-SqlCommand.ps1 | Invoke-SqlCommand.ps1 | ##############################################################################\n##\n## Invoke-SqlCommand\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nRe... |
PowerShellCorpus/PoshCode/Out-Colour.ps1 | Out-Colour.ps1 | function out-colour {
if ($Input) {
[int[]]$columns = @()
# select colors you prefer and the one that a readable on your console.. :)
$colours = @('Magenta','Yellow','Cyan','Green')
foreach ($obj in ($Input | Out-String -Stream)) {
if ($columns.count -eq 0) {
$match = $obj | Select-Str... |
PowerShellCorpus/PoshCode/VM Disk Report.ps1 | VM Disk Report.ps1 |
$VMs = get-vm
$Results = @()
foreach ($VM in $VMs) {
$Result = new-object PSObject
$Result | add-member -membertype NoteProperty -name "Name" -value $VM.Name
$Result | add-member -membertype NoteProperty -name "Description" -value $VM.Notes
$VMDiskCount = 1
get-harddisk $VM | foreach {
... |
PowerShellCorpus/PoshCode/AD_bulk_new_OU.ps1 | AD_bulk_new_OU.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/Create AD Test Lab.ps1 | Create AD Test Lab.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>Ted Wagner</Author>
### <Version='2.4'>
### <Script Name='Create-ADTestLabContent.ps1'>
### <Derived From='Dmitry Sotnikov - http://dmitrysotnikov.wordpress.com/2007/12/14/setting-demo-ad-environments/'>
### <De... |
PowerShellCorpus/PoshCode/Bash Aliases.ps1 | Bash Aliases.ps1 | ## Aliases Module, Bash-style aliases with functions
function alias {
# pull together all the args and then split on =
$alias,$cmd = [string]::join(" ",$args).split("=",2) | % { $_.trim()}
if($Host.Version.Major -ge 2) {
$cmd = Resolve-Aliases $cmd
}
New-Item -Path function: -Name "Global:... |
PowerShellCorpus/PoshCode/Backup all ESXi_1.ps1 | Backup all ESXi_1.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/ComObjects.Types.ps1 | ComObjects.Types.ps1 | <Types>
<Type>
<Name>System.__ComObject</Name>
<Members>
<ScriptMethod>
<Name>GetProperty</Name>
<Script>
param([Parameter(Mandatory=$true,Position=1)]$PropertyName)
Write-Verbose "PropertyName: $PropertyName"
Write-Ve... |
PowerShellCorpus/PoshCode/Set-Domain_6.ps1 | Set-Domain_6.ps1 | function Set-Domain {
param( [switch]$help,
[string]$domain=$(read-host "Please specify the domain to join"),
[System.Management.Automation.PSCredential]$credential = $(Get-Crdential)
)
$usage = "`$cred = get-credential `n"
$usage += "Set-AvaDomain -domain corp.avanade.org -credential `$cred`n"
... |
PowerShellCorpus/PoshCode/ScriptMethod Example.ps1 | ScriptMethod Example.ps1 | $x = New-Object PSObject |
Add-Member -MemberType ScriptMethod -Name Test -Value {
param($message=$(Read-Host "Message"))
return "This is the message: $message"
} -Passthru
# You should now call $x.Test("Hello World")
# But if you call $x.Test() it will prompt you for the $mess... |
PowerShellCorpus/PoshCode/70ca48ee-7e54-4a00-bf91-3c77792224ad.ps1 | 70ca48ee-7e54-4a00-bf91-3c77792224ad.ps1 | [void][system.reflection.Assembly]::LoadWithPartialName("MySql.Data")
# Open Connection
$connStr = "server=127.0.0.1;port=3306;uid=root;pwd=password;database=test;Pooling=False"
$conn = New-Object MySql.Data.MySqlClient.MySqlConnection($connStr)
$conn.Open()
# write the info
$sql = "INSERT INTO table1 (n... |
PowerShellCorpus/PoshCode/Join-Objects 3.0.ps1 | Join-Objects 3.0.ps1 | <#
.Synopsis
Performs a join of all properties from two objects
.Description
Joins the properties of two or more objects together to produce a single custom object
Support scriptblock evaluation, and joining objects from the pipeline
.Example
ls | Join-Object { $_ | Select BaseName } { $_.LastWrite... |
PowerShellCorpus/PoshCode/WPF PingMonitor for 1.0.ps1 | WPF PingMonitor for 1.0.ps1 | if(!(Get-Command New-BootsWindow -EA SilentlyContinue)) {
Add-PsSnapin PoshWpf
#Import-Module PowerBoots
#Add-BootsContentProperty 'DataPoints', 'Series'
[Void][Reflection.Assembly]::LoadFrom( (Convert-Path (Resolve-Path "~\\Documents\\WindowsPowershell\\Libraries\\WPFVisifire.Charts.dll")) )
#Add-B... |
PowerShellCorpus/PoshCode/2dbab092-67c9-4604-993a-656847e35f4b.ps1 | 2dbab092-67c9-4604-993a-656847e35f4b.ps1 | function Run-Script {
if ($psISE.CurrentFile.DisplayName.StartsWith("Untitled")) {
return
}
$script = $psISE.CurrentFile.DisplayName
$psISE.CurrentFile.Save()
$logfile = "$env:programfiles\\Sea Star Development\\" +
"Script Monitor Service\\ScriptMon.txt" #Change t... |
PowerShellCorpus/PoshCode/Set-OutlookSignature_1.ps1 | Set-OutlookSignature_1.ps1 | ###########################################################################"
#
# NAME: Set-OutlookSignature.ps1
#
# AUTHOR: Jan Egil Ring
#
# COMMENT: Script to create an Outlook signature based on user information from Active Directory.
# Adjust the variables in the "Custom variables"-section
# ... |
PowerShellCorpus/PoshCode/MVP PowerShell.ps1 | MVP PowerShell.ps1 | # (C) 2012 Dr. Tobias Weltner, MVP PowerShell
# www.powertheshell.com
# you can freely use and distribute this code
# we only ask you to keep this comment including copyright and url
# as a sign of respect.
# more information and documentation found here:
# http://www.powertheshell.com/iseconfig/
<#
.SYN... |
PowerShellCorpus/PoshCode/381c5978-c4cc-421e-9c0f-9ac6d9e14e61.ps1 | 381c5978-c4cc-421e-9c0f-9ac6d9e14e61.ps1 | <#
NAME: WLAN-functions.ps1
AUTHOR: Jan Egil Ring
EMAIL: jan.egil.ring@powershell.no
COMMENT: PowerShell functions to export and import WLAN profiles in Windows Vista/Windows 7
Required version: Windows PowerShell 2.0 (built-in to Windows 7)
Usage: Either copy the functions directly into... |
PowerShellCorpus/PoshCode/Security group monitor_1.ps1 | Security group monitor_1.ps1 | #Get group membership for a list of security
#groups and export to an XML for comparison
#against baseline.
#
$script:WorkingDirectory = split-path $myinvocation.Mycommand.Definition -parent
Function Re-Baseline
{
#First, declare array and hashtable.
$securitygroups = @()
$table = @{}
#Import Security... |
PowerShellCorpus/PoshCode/Email attachments.ps1 | Email attachments.ps1 | $file = "MYFILE.TXT"
$smtpServer = "MYSMTPSERVER.EMAIL.CO.UK"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($file)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "FROMME@EMAIL.CO.UK"
$msg.To.Add("TOME@EMAIL.CO.UK")
$msg.Subject = "MY SUBJECT"
$msg.Body = "MY... |
PowerShellCorpus/PoshCode/Start-IRCJabberBridge.ps1 | Start-IRCJabberBridge.ps1 | ##########################################################################################
## Depends on the PsXmppHelper.dll from http://CodePlex.com/PowerXmpp
## CONTAINS Read-HostMasked http://powershellcentral.com/scripts/104
## CONTAINS Out-Working http://powershellcentral.com/scripts/105
#####################... |
PowerShellCorpus/PoshCode/Test-SqlConnection.ps1 | Test-SqlConnection.ps1 | #######################
<#
Version History
v1.0 - Chad Miller - Initial release
#>
#######################
function Test-Ping
{
param([Parameter(Mandatory=$true, ValueFromPipeline = $true)] [string[]]$ComputerName)
process
{
$ComputerName | foreach {$result=Test-Connection -Compu... |
PowerShellCorpus/PoshCode/Invoke-Sql.ps1 | Invoke-Sql.ps1 | <#
.SYNOPSIS
Runs a T-SQL Query and optional outputs results to a delimited file.
.DESCRIPTION
Invoke-Sql script will run a T-SQL query or stored procedure and optionally outputs a delimited file.
.EXAMPLE
PowerShell.exe -File "C:\\Scripts\\Invoke-Sql.ps1" -ServerInstance "Z003\\sqlprod2" -Database orders -Query ... |
PowerShellCorpus/PoshCode/New-XVM_9.ps1 | New-XVM_9.ps1 | Function New-OSCVM
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory=$false,Position=1)]
[string]$ComputerName=$env:COMPUTERNAME,
[Parameter(Mandatory=$true,Position=2)]
[string]$Name,
[Parameter(Mandatory=$true,Position=3)]
[string]$SwitchNam... |
PowerShellCorpus/PoshCode/finddupe_5.ps1 | finddupe_5.ps1 | function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]'))
{
$stream = $null;
$cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider];
$hashAlgorithm = new-object $cryptoServiceProvider
$stream = $file.OpenRead();
$hashByteArray = $hashA... |
PowerShellCorpus/PoshCode/GET-NewPasswordPlus.ps1 | GET-NewPasswordPlus.ps1 | Function global:GET-NEWpassword( $Length, $Complexity) {
# $Length variable serves a dual Purpose
# It assumes nobody wants a tiny password less than
# 8 characters so anything less than than it used
# to pull up one of 8 predined password templates
If ($Length -eq $NULL) { $Length = 0 }
# If you're goi... |
PowerShellCorpus/PoshCode/ESXiMgmt module sample 1.ps1 | ESXiMgmt module sample 1.ps1 | #######################################################################################################################
# File: ESXiMgmt_machines_generation_sample.ps1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/VM Performance Report.ps1 | VM Performance Report.ps1 | <#
.SYNOPSIS
The script creates an HTML report for given vSphere VM's, that contains VM performance data over a given period. The script then emails the report to a given address.
.DESCRIPTION
The script requires an input file, supplied as an argument to the script. The first line of this file contains an e... |
PowerShellCorpus/PoshCode/Wireless Signal Strength.ps1 | Wireless Signal Strength.ps1 | # Wireless Statistics into object
# Author: Josh Popp
# Put Wireless Stats, like Signal Strengh, BSSID, and Channel into an object
# First just dump the netsh output into $wlanraw
$wlanraw = netsh wlan show interface
# Create the object as "empty"
$objWLAN = "" | Select-Object Name,SSID,BSSID,Channel... |
PowerShellCorpus/PoshCode/Send-Growl 3.1.ps1 | Send-Growl 3.1.ps1 | ## This is the first version of a Growl module (just dot-source to use in PowerShell 1.0)
## v 1.0 supports a very simple notice, and no callbacks
## v 2.0 supports registering multiple message types
## supports callbacks
## v 2.1 redesigned to be a module used from apps, rather than it's own "PowerGrowler" a... |
PowerShellCorpus/PoshCode/Power state.ps1 | Power state.ps1 | using System;
using System.IO;
using System.Reflection;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
[assembly: AssemblyCompany("greg zakharov")]
[assembly: AssemblyCopyright("Copyleft (C) 2007 greg zakharov")]
[assembly: AssemblyCulture("")]
[assembly: Assembly... |
PowerShellCorpus/PoshCode/USB Script backup.ps1 | USB Script backup.ps1 | ################################################################################
# Copy-Backup.ps1
# This script will backup recently changed .ps1 files from any selected folder
# (default is $pwd) to any number of inserted USB devices, on which an archive
# folder PSarchive will be created if it does not already... |
PowerShellCorpus/PoshCode/9a32cfaf-77be-4cae-8d11-f85a905dfa06.ps1 | 9a32cfaf-77be-4cae-8d11-f85a905dfa06.ps1 | param
(
[Parameter(Mandatory=$true, Position = 0, ValueFromPipeline=$true)]
[Parameter(HelpMessage="Specifies the path to the IIS *.log file to import. You can also pipe a path to Import-Iss-Log.")]
[ValidateNotNullOrEmpty()]
[string]
$Path,
[Parameter(Position = 1)]
[Parameter(HelpMessage="Specifies ... |
PowerShellCorpus/PoshCode/TabExpansion for V2CTP_3.ps1 | TabExpansion for V2CTP_3.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-Exchange-Mail_1.ps1 | Get-Exchange-Mail_1.ps1 | [Reflection.Assembly]::LoadFile("C:\\Program Files\\Microsoft\\Exchange\\Web Services\\1.1\\Microsoft.Exchange.WebServices.dll") | Out-Null
$s = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)
$s.Credentials = New-Object Net.Netwo... |
PowerShellCorpus/PoshCode/Report-RecipientCounts_1.ps1 | Report-RecipientCounts_1.ps1 | <#
.SYNOPSIS
Report-RecipientCounts.ps1
Keep a running total of daily recipient count distribution.
.DESCRIPTION
Keep a running total of daily recipient count distribution.
.PARAMETER Days
The number of days back to examine logs.
Default = 1 (Yesterday)
.EXAMPLE
Report-R... |
PowerShellCorpus/PoshCode/Import-Certificate_4.ps1 | Import-Certificate_4.ps1 | function Import-Certificate {\n<#\n .SYNOPSIS\n Imports certificate in specified certificate store.\n\n .DESCRIPTION\n Imports certificate in specified certificate store.\n\n .PARAMETER CertFile\n The certificate file to be imported.\n\n .PARAMETER StoreNames\n The certificate ... |
PowerShellCorpus/PoshCode/WSUS-Purge.ps1 | WSUS-Purge.ps1 | #==================================================================================================
# File Name : WSUS-Purge.ps1
# Original Author : Kenneth C. Mazie (kcmjr)
# Description : As written it will clear out files left over from Windows Updates.
# :
... |
PowerShellCorpus/PoshCode/NumLock Notifier.ps1 | NumLock Notifier.ps1 | <#
.NOTES
Name : NumLockNotifier.ps1
Author : Bryan Jaudon <bryan.jaudon@gmail.com>
Version : 1.0
Date : 10/25/2012
.Description
Adds a notification icon to show current NumLock status. Double clicking or by using the context menu, allows for
toggling of the NumLo... |
PowerShellCorpus/PoshCode/Get-CrawlHealth (MOSS)_1.ps1 | Get-CrawlHealth (MOSS)_1.ps1 | [reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") | out-null
@@#NOTE: I've set strict crawl freshness/crawl duration/success rati... |
PowerShellCorpus/PoshCode/ping check using dotNet .ps1 | ping check using dotNet .ps1 | function check-ping {
$erroractionpreference = "SilentlyContinue"
$ping = new-object System.Net.NetworkInformation.Ping
$rslt = $ping.send($args)
if ($rslt.status.tostring() –eq “Success”) {
write-host $args + “ ping worked”
}
else {
write-host $args + “ ping failed”
}
$ping = $null
}
|
PowerShellCorpus/PoshCode/Import-Iis-Log_1.ps1 | Import-Iis-Log_1.ps1 | param
(
[Parameter(
Mandatory=$true,
Position = 0,
ValueFromPipeline=$true,
HelpMessage="Specifies the path to the IIS *.log file to import. You can also pipe a path to Import-Iss-Log."
)]
[ValidateNotNullOrEmpty()]
[string]
$Path,
[Parameter(
Position = 1,
HelpMessage="Specifies the d... |
PowerShellCorpus/PoshCode/LoadModuleConfig_3.ps1 | LoadModuleConfig_3.ps1 | ################################################################################
## Script Name: LoadModuleConfig
## Created On: 01/21/2010
## Author: Thell Fowler
## File: LoadModuleConfig.ps1
## Usage: Called from the NestedModules value from a module manifest.
## Version:... |
PowerShellCorpus/PoshCode/SMS.psm1.ps1 | SMS.psm1.ps1 | # SystemsManagementServer.psm1
# written by Tojo2000 <tojo2000@tojo2000.com>
# Last updated on 20080921
#
# Functions for getting data from MS Systems Management Server.
# Set default server and site name here. It should be the server with the SMS
# Provider, not necessarily the site server.
[string]$def... |
PowerShellCorpus/PoshCode/Get-Parameter 1.2.ps1 | Get-Parameter 1.2.ps1 | function Get-Parameter
{
[OutputType('System.String')]
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[String]$Command,
[Parameter(Position=1)]
[String[]]$Name=@('*'),
[Parameter()]
[Validate... |
PowerShellCorpus/PoshCode/ESXiMgmt module sample 2.ps1 | ESXiMgmt module sample 2.ps1 | #######################################################################################################################
# File: ESXiMgmt_machines_poweron_sample.ps1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/CertMgmt pack_2.ps1 | CertMgmt pack_2.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/WriteFileName_3.ps1 | WriteFileName_3.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/Searching Word.ps1 | Searching Word.ps1 | $word=New-Object -COM "Word.Application"
$errorlog="c:\\missing.csv"
Set-Content $errorlog "Chapter,Script"
Get-ChildItem c:\\test\\*.doc | foreach {
$file=$_.fullname
Write-Host $file
$doc=$word.Documents.Open($file)
$style=$word.ActiveDocument.Styles |
where {$_.namelocal -eq "c... |
PowerShellCorpus/PoshCode/A Compare-Object Bug.ps1 | A Compare-Object Bug.ps1 | # I want do demonstrate a Compare-object bug
# Bernd Kriszio - http://pauerschell.blogspot.com/
1, 2, 3, 4, 5 > .\\textfile_a.txt
1, 2, 4, 5, 6 > .\\textfile_b.txt
cat .\\textfile_a.txt
cat .\\textfile_b.txt
compare-object (gc .\\textfile_a.txt) (gc .\\textfile_b.txt) -inc
<#yields
InputObject ... |
PowerShellCorpus/PoshCode/Get-Command (which).ps1 | Get-Command (which).ps1 | ## This ought to be the same as Get-Command, except...
## it will output the commands in the actual order they would be used by the shell
function which( [string]$command ) {
$Script:ErrorActionPreference = "SilentlyContinue"
Get-Command $command -commandType Alias
Get-Command $command -commandType Funct... |
PowerShellCorpus/PoshCode/Reverse filename sequenc.ps1 | Reverse filename sequenc.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/h20 - Hashtables to obje.ps1 | h20 - Hashtables to obje.ps1 | #hashtable to object function.
#used to be able to make custom objects with math inside the pipeline
#e.g. 1..10 | h20 { @{karl = $_;dude = $_+1} }
# gps | h20 { @{name = $_.processname; mem = $_.workingset / 1MB} }
function h20([scriptblock]$sb )
{
begin {}
process{ if ($sb -ne $null)
{
... |
PowerShellCorpus/PoshCode/Set-OCSUser.ps1 | Set-OCSUser.ps1 | ###########################################################################"
#
# NAME: Set-OCSUser.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: Requires Quest AD cmdlets. This oneliner sets Active Directory user attributes for Microsoft Office Communications Server 2007.
# ... |
PowerShellCorpus/PoshCode/Highlight-Syntax _2.0.ps1 | Highlight-Syntax _2.0.ps1 | #requires -version 2.0
# Highlight-Syntax.ps1
# version 2.0
# by Jeff Hillman
#
# this script uses the System.Management.Automation.PsParser class
# to highlight PowerShell syntax with HTML.
param( [string] $code, [switch] $LineNumbers )
if ( Test-Path $code -ErrorAction SilentlyContinue )
{
$code =... |
PowerShellCorpus/PoshCode/Get-GroupMembership_1.ps1 | Get-GroupMembership_1.ps1 | ## Get-DistinguishedName -- look up a DN from a user's (login) name
function Get-DistinguishedName {
Param($UserName)
$ads = New-Object System.DirectoryServices.DirectorySearcher([ADSI]'')
$ads.filter = "(&(objectClass=Person)(samAccountName=$UserName))"
$s = $ads.FindOne()
return $s.GetDirectoryEnt... |
PowerShellCorpus/PoshCode/Xml Module 4.3.ps1 | Xml Module 4.3.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/Get-WebFile 3.7.1.ps1 | Get-WebFile 3.7.1.ps1 | ## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.7.1 - Puts a try-catch statement around the $req.GetResponse() call to prevent further execution if
## ... |
PowerShellCorpus/PoshCode/Get-CInfo.ps1 | Get-CInfo.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/Import-Certificate.ps1 | Import-Certificate.ps1 | function Import-Certificate
{
param
(
[IO.FileInfo] $CertFile = $(throw "Paramerter -CertFile [System.IO.FileInfo] is required."),
[string[]] $StoreNames = $(throw "Paramerter -StoreName [System.String] is required."),
[switch] $LocalMachine,
[switch] $CurrentUser,
[string] $CertPassword,
[switch... |
PowerShellCorpus/PoshCode/Get-StaticMethodDefin_1.ps1 | Get-StaticMethodDefin_1.ps1 | #Steven Murawski
#http://blog.usepowershell.com
#03/20/2009
#Examples:
# get-staticmethoddefinition max math
# [math] | get-staticmethoddefinition max
function Get-StaticMethodDefinition()
{
param ([string[]]$Method, [Type]$Type=$null)
BEGIN
{
if ($Type -ne $null)
{
$Type | Get-StaticMethodDe... |
PowerShellCorpus/PoshCode/Create a VIAccount.ps1 | Create a VIAccount.ps1 | function New-VIAccount($principal) {
$flags = `
[System.Reflection.BindingFlags]::NonPublic -bor
[System.Reflection.BindingFlags]::Public -bor
[System.Reflection.BindingFlags]::DeclaredOnly -bor
[System.Reflection.BindingFlags]::Instance
$method = $defaultviserver.GetType().GetMethods($flags) |... |
PowerShellCorpus/PoshCode/Get-InstalledApps.ps1 | Get-InstalledApps.ps1 | Param([string]$server)
Begin{
function CheckRegKey{
param([string]$srv)
$key = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$type = [Microsoft.Win32.RegistryHive]::LocalMachine
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv)
$regKey... |
PowerShellCorpus/PoshCode/HuddledTricks.ps1 | HuddledTricks.ps1 | ## Stupid PowerShell Tricks
###################################################################################################
## Usage:
## ps Notepad | Hide-App
## Hide-App -Name PowerShell; Wiggle-Mouse 75 100
###################################################################################################
a... |
PowerShellCorpus/PoshCode/Test-Help_1.ps1 | Test-Help_1.ps1 | function Test-Help {
<#
.Synopsis
Test-Help -Function Get-USB
.Description
Test-Help was written to get information why that !@##$%#$%# help is not working ;)
Should work fine both with v1 and v2 comments.
Using fancy regex that probably could be shorter, more elegant ... |
PowerShellCorpus/PoshCode/VB MsgBox Powershell.ps1 | VB MsgBox Powershell.ps1 | <#
.SYNOPSIS
Shows a graphical message box, with various prompt types available.
.DESCRIPTION
Emulates the Visual Basic MsgBox function. It takes four parameters, of which only the prompt is mandatory
.INPUTS
The parameters are:... |
PowerShellCorpus/PoshCode/Determine Computer Uptim.ps1 | Determine Computer Uptim.ps1 | <#
.SYNOPSIS
Demonstrates uptime using WMI
.DESCRIPTION
This script used Win32_ComputerSystem to determine how long your system
has been running. This is a rewrite/improvement of sample 3 at
http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx.
.NOTES
File Name : Get-UpTime.ps1
... |
PowerShellCorpus/PoshCode/Automount new PSDrives.ps1 | Automount new PSDrives.ps1 | # AutoMount.psm1 v1.0
# Oisin "x0n" Grehan (MVP)
$query = new-object System.Management.WqlEventQuery
$query.EventClassName = "__InstanceOperationEvent"
# default to every 2 seconds
$query.WithinInterval = new-object System.TimeSpan 0,0,2
@@# this WMI is only available with Windows 200... |
PowerShellCorpus/PoshCode/Update-DeptGPOs.ps1 | Update-DeptGPOs.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/Get-Tree_1.ps1 | Get-Tree_1.ps1 | #.Synopsis
# Creates a fir tree in your console!
#.Description
# A simple christmas tree simulation with (optional) flashing lights.
# Requires your font be set to a True Type font (best results with Consolas).
#.Parameter Trim
# Whether or not to trim the tree. NOTE: In violation of convention, this switch ... |
PowerShellCorpus/PoshCode/Get-InstalledProgram_v_2.ps1 | Get-InstalledProgram_v_2.ps1 | function Get-InstalledProgram() {
param (
[String[]]$Computer,
$User
)
if ($User -is [String]) {
$Connection = Get-Credential -Credential $User
}
if ($Connection -eq $null){
foreach ($Comp in $Computer){
$Install_soft = gwmi win32_product -ComputerName $Comp |
where {$_.vendor -notlike ... |
PowerShellCorpus/PoshCode/New-ZipFile.ps1 | New-ZipFile.ps1 | ##############################################################################\n##\n## New-ZipFile\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 a Zip... |
PowerShellCorpus/PoshCode/Set-PrimaryDnsSuffix_1.ps1 | Set-PrimaryDnsSuffix_1.ps1 | function Set-PrimaryDnsSuffix {
param ([string] $Suffix)
# http://msdn.microsoft.com/en-us/library/ms724224(v=vs.85).aspx
$ComputerNamePhysicalDnsDomain = 6
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
namespace ComputerSystem {
public class Identification ... |
PowerShellCorpus/PoshCode/Get-RelativePath.ps1 | Get-RelativePath.ps1 | function Get-RelativePath {
<#
.SYNOPSIS
Get a path to a file (or folder) relative to another folder
.DESCRIPTION
Converts the FilePath to a relative path rooted in the specified Folder
.PARAMETER Folder
The folder to build a relative path from
.PARAMETER FilePath
The File (or folder) to build a re... |
PowerShellCorpus/PoshCode/VM Performance Report_4.ps1 | VM Performance Report_4.ps1 | <#
.SYNOPSIS
The script creates an HTML report for given vSphere VM's, that contains VM performance data over a given period. The script then emails the report to a given address.
.DESCRIPTION
The script requires an input file, supplied as an argument to the script. The first line of this file contains an e... |
PowerShellCorpus/PoshCode/Find-GeoCode.ps1 | Find-GeoCode.ps1 | $mappoint = New-WebServiceProxy http://staging.mappoint.net/standard-30/mappoint.wsdl -Namespace MapPoint
$FindService = new-object MapPoint.FindServiceSoap
# You need an account, sign up here: https://mappoint-css.live.com/mwssignup
$FindService.Credentials = Get-Credential
function Find-ReverseGeoCode( [double... |
PowerShellCorpus/PoshCode/Invoke-ScriptBlock.ps1 | Invoke-ScriptBlock.ps1 | ##############################################################################\n##\n## Invoke-ScriptBlock\n##\n## From Windows PowerShell, The Definitive Guide (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNO... |
PowerShellCorpus/PoshCode/Exch07 Quota Report.ps1 | Exch07 Quota Report.ps1 | #Get information on everybodies inbox and spit it out with total sizes #in MB. Sorts the list by StorageLimitStatus
#NOTE THAT I HAD TO USE ASCII WITH OUT-FILE AS NO OTHER ENCODING WOULD #PROPERLY IMPORT CSV INTO EXCEL
#create a date var to stick in the filename
$date = get-date -Format MM-dd-yyyy
#create a ou... |
PowerShellCorpus/PoshCode/Write-FileInfoToSQL.ps1 | Write-FileInfoToSQL.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller
### </Author>
### <Description>
### Reports data model directories and bool value as to whether they have
### an htm file of the same name as the project directory.
### </Description>
### <U... |
PowerShellCorpus/PoshCode/CreateVDS_1.ps1 | CreateVDS_1.ps1 | function CreateVDS(
$vdsName, $datacenter, $vmHost, $physicalNic, $portGroupType = "earlyBinding", `
[array]$portGroupNameList = @(),[array]$uplinkList = @() ) {
# ------- Create vDS ------- #
$vdsCreateSpec = New-Object VMware.Vim.DVSCreateSpec
$vdsCreateSpec.configSpec = New-Object VMware.V... |
PowerShellCorpus/PoshCode/GeSHi PowerShell Syntax .ps1 | GeSHi PowerShell Syntax .ps1 | <?php
/*************************************************************************************
* posh.php
* ---------------------------------
* Author: Joel Bennett (Jaykul@HuddledMasses.org)
* Copyright: (c) 2007 Joel Bennett (http://HuddledMasses.org/)
* Release Version: 1.1.0
* Date Started: 2007-06-08
... |
PowerShellCorpus/PoshCode/Help Differ 10000 v_1.01.ps1 | Help Differ 10000 v_1.01.ps1 | # These functions are meant to help generate a table that shows differences between
# cmdlets among different versions of a module.
# You will need a MoinMoin wiki to render the output.
# If you don't have a MoinMoin wiki you might be able to use the sandbox at http://moinmo.in/WikiSandBox
# Extracts some data fr... |
PowerShellCorpus/PoshCode/Reset-Tray.ps1 | Reset-Tray.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 SendMouseMov... |
PowerShellCorpus/PoshCode/Get-FileEncoding_1.ps1 | Get-FileEncoding_1.ps1 | function Get-FileEncoding {
<#
.SYNOPSIS
Gets file encoding.
.DESCRIPTION
The Get-FileEncoding function determines encoding by looking at Byte Order Mark (BOM).
Based on port of C# code from http://www.west-wind.com/Weblog/posts/197245.aspx
.EXAMPLE
Get-ChildItem *.ps1 | select FullName, @{n='Encoding';e={Get-... |
PowerShellCorpus/PoshCode/Query-VeeamBackupDB.ps1 | Query-VeeamBackupDB.ps1 | $dbServer = "servername\\instance"
$db = "VeeamBackup"
$veeamJob = "VeeamJobName"
$Query = "SELECT [job_name],CONVERT(char(10),[creation_time], 101) AS start_date `
,CONVERT(varchar, [creation_time], 108) AS job_start,CONVERT(char(10), [end_time], 101) AS end_date `
,CONVERT(varchar, [end_time], 108) AS job_end, `... |
PowerShellCorpus/PoshCode/chkhash_13.ps1 | chkhash_13.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/Get_Set Signature (CTP3).ps1 | Get_Set Signature (CTP3).ps1 | #Requires -version 2.0
## Authenticode.psm1 updated for CTP 3
####################################################################################################
## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets
## These properly parse paths, so they don't kill your pipeline and ... |
PowerShellCorpus/PoshCode/Sith Remote logon mon.ps1 | Sith Remote logon mon.ps1 | ' Script: Process_Monitor.vbs
' Purpose: Live process monitoring script that will trigger an e-mail to a recipient if a certain process is started
' Author: Paperclips (The Dark Lord)
' Email: magiconion_M@hotmail.com
' Date: Feb 2011
' Comments: This particular monitor monitors the LogonUI proce... |
PowerShellCorpus/PoshCode/Write-Output_1.ps1 | Write-Output_1.ps1 | ########################################################################
## Copyright (c) Joel Bennett, 2010
## Free for use under MS-PL, MS-RL, GPL 2, or BSD license. Your choice.
function Write-Output {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)]
[Allow... |
PowerShellCorpus/PoshCode/Get-Credential++.ps1 | Get-Credential++.ps1 | ## Get-Credential
## An improvement over the default cmdlet which has no options ...
###################################################################################################
## History
## v 2.0 Rewrite for v2 to replace the default Get-Credential
## v 1.2 Refactor ShellIds key out to a variable, and wr... |
PowerShellCorpus/PoshCode/SetDefaultPrinter.ps1 | SetDefaultPrinter.ps1 | <#
.SYNOPSIS
Sets the Default Printer for any user on any machine in active directory.
.DESCRIPTION
Search AD for Computername; Select UserAccount and Printer and make that printer the default
printer for that user on that computer.
.PARAMETER Hostnme
This parameter is required and should reflect the c... |
PowerShellCorpus/PoshCode/Get-DiskUsage_3.ps1 | Get-DiskUsage_3.ps1 | Function Get-DiskUsage {
<#
.SYNOPSIS
A tribute to the excellent Unix command DU.
.DESCRIPTION
This command will output the full path and the size of any object
and it's subobjects. Using just the Get-DiskUsage command without
any parameters will result in an output of the directory you are
currently p... |
PowerShellCorpus/PoshCode/LibraryLinkedServer.ps1 | LibraryLinkedServer.ps1 | try {add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" -EA Stop}
catch {add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo"}
try {add-type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=8... |
PowerShellCorpus/PoshCode/Computer Inventory.ps1 | Computer Inventory.ps1 | # ========================================================
#
# Script Information
#
# Title: Remote Computer Inventory
# Author: Assaf Miron
# Originally created: 21/06/2008
# Original path: Computer-Inventory.PS1
# Description: Collects Remote Computer Data Using WMI and Registry Access
# Outputs... |
PowerShellCorpus/PoshCode/Get VMs on a LUN.ps1 | Get VMs on a LUN.ps1 | function Get-LunVM {
param($Lun)
Get-VM | Where {
$_ | Get-Stat -stat disk.write.average -realtime -maxsamples 1 `
-erroraction SilentlyContinue |
Where { $_.Instance -eq $Lun } }
}
|
PowerShellCorpus/PoshCode/The Letter Diamond Oneli.ps1 | The Letter Diamond Oneli.ps1 | &{Param([char]$l)$s=66;$z=[int]$l;$o=$z-$s+ 5;$p=-1;$n=&{"$(" "*$o)A";([string[]][char[]]($s..$z))|%{$p+=2;$o--;"$(" "*$o)$_$(" "*$p)$_"}};$n;$n[$($n.Length-2)..0]}L
|
PowerShellCorpus/PoshCode/LoadModuleConfig_1.ps1 | LoadModuleConfig_1.ps1 | ################################################################################
## Script Name: LoadModuleConfig
## Created On: 01/21/2010
## Author: Thell Fowler
## File: LoadModuleConfig.ps1
## Usage: Called from the NestedModules value from a module manifest.
## Version:... |
PowerShellCorpus/PoshCode/scriptable telnet client_2.ps1 | scriptable telnet client_2.ps1 | function read-stream ([Parameter(Position=0,Mandatory=$true)][validatenotnull()]
[System.Net.Sockets.NetworkStream]$stream,
[String]$expect = "")
{
$buffer = new-object system.byte[] 1024
$enc = new-object system.text.asciiEncoding
## Read all the data available from the stream, writing it to the
## s... |
PowerShellCorpus/PoshCode/Get-MemberBody.ps1 | Get-MemberBody.ps1 | #Requires ILSpy.
#Tested with version 2.1.0.1603
#http://ilspy.net/
Add-Type -Path "Mono.Cecil.dll"
Add-Type -Path "ICSharpCode.Decompiler.dll"
[void][System.Reflection.Assembly]::LoadFrom("ILSpy.exe")
function Get-MemberBody
{
[CmdletBinding()]
param(
[Parameter(ParameterSetName="MI")]
[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.