full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Get-SRVPriority.ps1 | Get-SRVPriority.ps1 | #Returns the priority SRV hostname and port for a particular service and domain.
function Get-SRVPriority {
param( [string] $query = $( Throw "Query required in the format _Service._Proto.DomainName (ie, `"_ftp._tcp.myserver.net`" or `"_xmpp-client._tcp.gmail.com`").") )
#get all the SRV records for this servic... |
PowerShellCorpus/PoshCode/AD Exch Users to Groups.ps1 | AD Exch Users to Groups.ps1 | ##Purpose: Search Active Directory for all users, add them to specific groups based on homemta value, remove disabled users from same groups, and export all users to excel.
##Requires Excel 2003 or 2007 be installed on the local machine for exporting.
##Requires Quest ActiveRoles Management Shell for Active Direct... |
PowerShellCorpus/PoshCode/Delete Empty Folders.ps1 | Delete Empty Folders.ps1 | $Drive = Read-Host "Path to Folders"
Write-Host "This will delete all empty folders in this directory!"
$a = Get-ChildItem $drive -recurse | Where-Object {$_.PSIsContainer -eq $True}
$a | Where-Object {$_.GetFiles().Count -lt 1} | Select-Object FullName | ForEach-Object {remove-item $_.fullname -recurse}
Write-Hos... |
PowerShellCorpus/PoshCode/CertMgmt pack_5.ps1 | CertMgmt pack_5.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/Get-Delegate.ps1 | Get-Delegate.ps1 | ## Get-Delegate.ps1\n###################################################################################################\n## Use Reflection and IL to emit arbitrary delegates ...\n## A trick they taught us on the PowerShell blog\n## http://blogs.msdn.com/powershell/archive/2006/07/25/678259.aspx\n######################... |
PowerShellCorpus/PoshCode/62334bcd-6366-4c6e-b6ae-220d2a0dc2f5.ps1 | 62334bcd-6366-4c6e-b6ae-220d2a0dc2f5.ps1 | ## Tab-Completion
#################
## Please dot souce this script file.
## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list.
## What this can do is:
##
## [datetime]::n<tab>
## [datetime]::now.d<tab>
## $a = New-Object "Int32[,]" 2,3; $b = "PowerShell","PowerShe... |
PowerShellCorpus/PoshCode/rajabatak@my.opera.com.ps1 | rajabatak@my.opera.com.ps1 | $ewsPath = "C:\\Program Files\\Microsoft\\Exchange\\Web Services\\1.1\\Microsoft.Exchange.WebServices.dll"
Add-Type -Path $ewsPath
$ews = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService -ArgumentList "Exchange2007_SP1"
$cred = (Get-Credential).GetNetworkCredential()
$ews.Credentials = New-Object Sy... |
PowerShellCorpus/PoshCode/dvSwitchNetworkAdapter.ps1 | dvSwitchNetworkAdapter.ps1 | <#
.SYNOPSIS
Retrieves the virtual network adapters available on a vSphere server.
.DESCRIPTION
A replacement for the default cmdlet will work with either a standard vSwitch or a dvSwitch.
Retrieves the virtual network adapters available on a vSphere server.
.PARAMETER VM
... |
PowerShellCorpus/PoshCode/Disable-CopyPasta-1.ps1 | Disable-CopyPasta-1.ps1 | Begin {
$disableCopy = "isolation.tools.copy.enable"
$disableCopy_value = "false"
$disablePaste = "isolation.tools.paste.enable"
$disablePaste_value = "false"
$disableGUI = "isolation.tools.setGUIOptions.enable"
$disableGUI_value = "false"
}
Process {
#Ma... |
PowerShellCorpus/PoshCode/Get Old Outlook Events.ps1 | Get Old Outlook Events.ps1 | # Copyright (c) 2011, Chris Cmolik <chris@chriscmolik.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# not... |
PowerShellCorpus/PoshCode/Get-Netstat 1,1.ps1 | Get-Netstat 1,1.ps1 | $null, $null, $null, $null, $netstat = netstat -a -n -o
[regex]$regexTCP = '(?<Protocol>\\S+)\\s+((?<LAddress>(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.(2[0-4]\\d|25[0-5]|[01]?\\d\\d?))|(?<LAddress>\\[?[0-9a-fA-f]{0,4}(\\:([0-9a-fA-f]{0,4})){1,7}\\%?\\d?\\... |
PowerShellCorpus/PoshCode/Start-Encryption_3.ps1 | Start-Encryption_3.ps1 | ## Start-Encryption
##################################################################################################
## Rijndael symmetric key encryption ... with no passes on the key. Very lazy.
## USAGE:
## $encrypted = Encrypt-String "Oisin Grehan is a genius" "P@ssw0rd"
## Decrypt-String $encrypted "P@ssw0rd... |
PowerShellCorpus/PoshCode/Update-SysinternalsSuite.ps1 | Update-SysinternalsSuite.ps1 | <#
.Synopsis
Update Sysinternals Suite.
.DESCRIPTION
Use PowerShell v3's Invoke-WebRequest do download the latest Sysinternals Tools from: http://live.sysinternals.com. Supports -AsJob
.EXAMPLE
Update-SysinternalsSuite -Path C:\\tools\\sysinterals
This Example downloads all sysinternals tools to C:\\... |
PowerShellCorpus/PoshCode/Get-HostEntry.ps1 | Get-HostEntry.ps1 | param (
[parameter(Mandatory=$true, ValueFromPipeline=$true)]
[String[]]$HostnameOrIPs
)
process {
ForEach ($HostnameOrIP in $HostnameOrIPs) {
try {
$result = [System.Net.Dns]::GetHostEntry($HostnameOrIP)
"" | select @{Name='HostName'; Expression={$result.HostName}}, @{Name='AddressList'; Expression... |
PowerShellCorpus/PoshCode/Get-WebFile 1.0.ps1 | Get-WebFile 1.0.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Joel "Jaykul" Bennett
### </Author>
### <Description>
### Downloads a file from the web to the specified file path.
### </Description>
### <Usage>
### Get-URL http://huddledmasses.org/downloads/RunOnlyOn... |
PowerShellCorpus/PoshCode/VBScript from cmd__bat.ps1 | VBScript from cmd__bat.ps1 | @set @script=0 /*
@echo off
set @script=
cscript //nologo //e:jscript "%~dpnx0"
exit /b
*/
//extracting VBScript source code from Source()
function ExtractCode(text, index) {
try {
return text.toString().split(/\\/\\*|\\*\\//)[index * 2 + 1];
}
catch (e) {}
}
//this execute VBScr... |
PowerShellCorpus/PoshCode/Resizer of pictures_1.ps1 | Resizer of pictures_1.ps1 | [reflection.assembly]::LoadWithPartialName("System.Drawing")
$SizeLimit=1280 # required size of picture's long side
$logfile="resizelog.txt" # log file for errors
$toresize=$args[0] # list of directories to find and resize images. can be empty
if ([string]$toresize -eq “”) { # if scr... |
PowerShellCorpus/PoshCode/Get-User_9.ps1 | Get-User_9.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/validate an IP address_2.ps1 | validate an IP address_2.ps1 | # validate given IP address in $ip1 variable
$ip1=read-host "Enter any IP Address"
($ip1.split(".") | where-object { ([int]$_) -ge 1 -and ([int]$_) -le 255 } | Where-Object { $_ -match "\\d{1,3}"} | Measure-Object).count -eq 4
|
PowerShellCorpus/PoshCode/WriteFileName_2.ps1 | WriteFileName_2.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/Write-Log_5.ps1 | Write-Log_5.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/Monitor ESX with WS-MAN_1.ps1 | Monitor ESX with WS-MAN_1.ps1 | function Get-VMHostWSManInstance {
param (
[Parameter(Mandatory=$TRUE,HelpMessage="VMHosts to probe")]
[VMware.VimAutomation.Client20.VMHostImpl[]]
$VMHost,
[Parameter(Mandatory=$TRUE,HelpMessage="Class Name")]
[string]
$class,
[switch]
$ignoreCertFailures,
[System.Management.Automation.PSCred... |
PowerShellCorpus/PoshCode/IE Proxy Toggle (Silent)_1.ps1 | IE Proxy Toggle (Silent)_1.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/Watch-Process.ps1 | Watch-Process.ps1 | ## Watch-Process.ps1
## Continuously display a process list, sorted
## by the desired criteria.
##
## usage: poll-process [sortCriteria] [pollInterval]
##
## sortCriteria must be one of "Id", "ProcessName", "MainWindowTitle",
## "Processor", "Disk", or "WorkingSet"
## pollInterval ... |
PowerShellCorpus/PoshCode/PowerShell Template_3.ps1 | PowerShell Template_3.ps1 | Function New-Script
{
$strName = $env:username
$date = get-date -format d
$name = Read-Host "Filename"
if ($name -eq "") { $name="NewTemplate" }
$email = Read-Host "eMail Address"
if ($email -eq "") { $email="genemagerr@hotmail.com" }
$comment=@();
while($s = (Read-Host "Comment").Trim()){$comment+="$s`r`n#"}
... |
PowerShellCorpus/PoshCode/ScriptTransforms module_3.ps1 | ScriptTransforms module_3.ps1 | function New-ParameterTransform {
#.Synopsis
# Generates Parameter Transformation Attributes in simple PowerShell syntax
#.Description
# New-ParameterTransform allows the creation of .Net Attribute classes which can be applied to PowerShell parameters to transform or manipulate data as it's being passed in.
#.Exam... |
PowerShellCorpus/PoshCode/Check Chromium Build.ps1 | Check Chromium Build.ps1 | # Name : Check-LatestChromium.ps1
# Author: David "Makovec" Moravec
# Web : http://www.powershell.cz
# Email : powershell.cz@googlemail.com
#
# Description: Check latest Chromium build
# : Uses HttpRest http://poshcode.org/787
#
# Version: 0.1
# History:
# v0.1 - (add) build check
# - (a... |
PowerShellCorpus/PoshCode/Start-Cassini_1.ps1 | Start-Cassini_1.ps1 | function Start-Cassini([string]$physical_path=((@(Coalesce-Args (Find-File Global.asax).DirectoryName "."))[0]), [int]$port=12372, [switch]$dontOpenBrowser) {
$serverLocation = Resolve-Path "C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\DevServer\\10.0\\WebDev.WebServer40.EXE";
$full_app_path = Resolve... |
PowerShellCorpus/PoshCode/Invoke-NamedParameter.ps1 | Invoke-NamedParameter.ps1 | Function Invoke-NamedParameter {
<#
.SYNOPSIS
Invokes a method using named parameters.
.DESCRIPTION
A function that simplifies calling methods with named parameters to make it easier to deal with long signatures and optional parameters. This is particularly helpful for COM objects.
.PARAMETER Object
... |
PowerShellCorpus/PoshCode/Export-CSV -Append.ps1 | Export-CSV -Append.ps1 | #Requires -Version 2.0
<#
This Export-CSV behaves exactly like native Export-CSV
However it has one optional switch -Append
Which lets you append new data to existing CSV file: e.g.
Get-Process | Select ProcessName, CPU | Export-CSV processes.csv -Append
For details, see
http://dmitrysotnikov.w... |
PowerShellCorpus/PoshCode/Get-NestedGroups_1.ps1 | Get-NestedGroups_1.ps1 | <#
.SYNOPSIS
Enumerate all AD group memberships of an account (including nested membership).
.DESCRIPTION
This script will return all the AD groups an account is member of.
.PARAMETER UserName
The username whose group memberships to find.
.EXAMPLE
.\\Get-NestedGroups.ps1 'johndoe'
Name ... |
PowerShellCorpus/PoshCode/Set-SendAs_1.ps1 | Set-SendAs_1.ps1 | # NAME
# Set-SendAs
#
# SYNOPSIS
# Use the Set-SendAs cmdlet to grant or Remove SendAs permissions on a mailbox
#
# SYNTAX
# Set-SendAs -Identity <MailboxIdParameter> -SendAs <MailboxIdParameter> -ou <OrganizationalUnit> [-Remove <SwitchParameter> [-Confirm [<SwitchParameter>]]] [-DomainController <Fqdn>]
... |
PowerShellCorpus/PoshCode/Spin-Busy.ps1 | Spin-Busy.ps1 | function Spin-Busy {
param(
[Int] $msWait = 0,
[String] $spinStr = '-\\|/. ',
[Char[]] $spinChars = [Char[]] ($spinStr.ToCharArray()),
[System.Management.Automation.Host.PSHostRawUserInterface] $rawUI = (Get-Host).UI.RawUI,
[ConsoleColor] $bgColor = $... |
PowerShellCorpus/PoshCode/Twitter Module v0.2b.ps1 | Twitter Module v0.2b.ps1 | <#
-------------------------------------------------------------------------------
Name: Social Media Scripting Framework
Module: Twitter
Version: 0.2 BETA
Date: 2013/02/03
Author: Carlos Veira Lorenzo
e-mail: cveira [at] thinkinbig [dot] org
blog: thinkinbig.org
twitte... |
PowerShellCorpus/PoshCode/Get_Set Signature (CTP2)_4.ps1 | Get_Set Signature (CTP2)_4.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/ESXi Config Backup Scrip_1.ps1 | ESXi Config Backup Scrip_1.ps1 | **********EDIT: See Carter's Example, it's way simpler: http://poshcode.org/1559**********
###ESXi Configuration Backup Script
#DESCRIPION: This Script takes a CSV file with the hostname, username, and password of a list of ESXi servers, and backs up their configurations to a specified Destination
#USAGE: This scr... |
PowerShellCorpus/PoshCode/Register-TemporaryEvent..ps1 | Register-TemporaryEvent..ps1 | ##############################################################################\n##\n## Register-TemporaryEvent\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/Quest Dynamic Group 005.ps1 | Quest Dynamic Group 005.ps1 | <#
2012.07.06
Information will be uploaded shortly.
#>
|
PowerShellCorpus/PoshCode/List AD Users CSV_3.ps1 | List AD Users CSV_3.ps1 | $NumDays = 0
$LogDir = ".\\User-Accounts.csv"
$currentDate = [System.DateTime]::Now
$currentDateUtc = $currentDate.ToUniversalTime()
$lltstamplimit = $currentDateUtc.AddDays(- $NumDays)
$lltIntLimit = $lltstampLimit.ToFileTime()
$adobjroot = [adsi]''
$objstalesearcher = New-Object System.DirectoryServices.Dire... |
PowerShellCorpus/PoshCode/Save-Credentials_5.ps1 | Save-Credentials_5.ps1 | <#
.SYNOPSIS
The script saves a username and password, encrypted with a custom key to to a file.
.DESCRIPTION
The script saves a username and password, encrypted with a custom key to to a file. The key is coded into the script but should be changed before use. The key allows the password to be decrypted ... |
PowerShellCorpus/PoshCode/New-ComplexPassword.ps1 | New-ComplexPassword.ps1 | # $Id: New-ComplexPassword.ps1 170 2008-09-05 19:49:48Z jon $
# $Revision: 170 $
Function New-ComplexPassword ([int]$Length=8, $digits=$null, $alphaUpper=$null, $alphaLower=$null, $special=$null)
{
# ASCII data taken from http://msdn2.microsoft.com/en-us/library/60ecse8t(VS.80).aspx
# Make sure the passwo... |
PowerShellCorpus/PoshCode/Connect-WebService.ps1 | Connect-WebService.ps1 | ##############################################################################\n##\n## Connect-WebService\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n## Connect to a given web service, and create a type that allows you to\n## interact with that web service... |
PowerShellCorpus/PoshCode/Get-Characteristics.ps1 | Get-Characteristics.ps1 | ##############################################################################\n##\n## Get-Characteristics\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\nGet ... |
PowerShellCorpus/PoshCode/Get-MWSOrder.ps1 | Get-MWSOrder.ps1 | // --------------------------------------------------------------------------------------------------------------------
// <copyright file="GetOrderCmdlet.cs" company="Huddled Masses">
// Copyright (c) 2011 Joel Bennett
// </copyright>
// <summary>
// Defines the Get-Order Cmdlet for Amazon Marketplace Orders ... |
PowerShellCorpus/PoshCode/Users_Contacts from CSV.ps1 | Users_Contacts from CSV.ps1 | #=============================================================================#
#=============================================================================#
#=============================================================================#
#
# SCRIPT : CreateOrUpdateUsersOrContacts.ps1
# LAST UPDATE : 9/18/2009... |
PowerShellCorpus/PoshCode/Sybase Error Log Check.ps1 | Sybase Error Log Check.ps1 |
# Description
# ===========
# This script is to check the Sybase ASE Server errorlog for certain strings... |
PowerShellCorpus/PoshCode/Send-HTMLFormattedEmail_6.ps1 | Send-HTMLFormattedEmail_6.ps1 | ##################################################
# cmdlets
##################################################
#-------------------------------------------------
# Send-HTMLFormattedEmail
#-------------------------------------------------
# Usage: Send-HTMLFormattedEmail -?
#------------------------------------... |
PowerShellCorpus/PoshCode/Write-Log System Center.ps1 | Write-Log System Center.ps1 | function Write-Log
{
<#
.Synopsis
Write a message to a log file in a format compatible with Trace32 and Config Manager logs.
.Description
This cmdlet takes a given message and formats that message such that it's compatible with
the Trace32 log viewer tool used for reading/parsing Syst... |
PowerShellCorpus/PoshCode/Select-Alive_1.ps1 | Select-Alive_1.ps1 | ## this filer passes through only objects that are pingable
## it takes any object as input, but the property containing the hostname
## to ping must be specified if the object is not a string
function Select-Alive {param( [object]$InputObject,
[string]$Property,
[int32]$Requests = 3,
[switch]$Verbose... |
PowerShellCorpus/PoshCode/Get-User_11.ps1 | Get-User_11.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/Create VApps in vSphere.ps1 | Create VApps in vSphere.ps1 | <#
.SYNOPSIS
Creates VApps within DevStack with reservations for CPU & RAM
.DESCRIPTION
Creates VApps within DevStack vSphere Environment, available parameters are:
-VIServer (Optional, defaults to DevStack) {FQDN of VCentre Server}
-AppName (Required) {VApp Label}
-Location (Required) {Managed | Un-mana... |
PowerShellCorpus/PoshCode/Get-DiskSizeInfo_1.ps1 | Get-DiskSizeInfo_1.ps1 | Function Get-DiskSizeInfo {
<#
.DESCRIPTION
Check the Disk(s) Size and remaining freespace.
.PARAMETER ComputerName
Specify the computername(s)
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSObject
.EXAMPLE
... |
PowerShellCorpus/PoshCode/Get-PipeLineObject_1.ps1 | Get-PipeLineObject_1.ps1 | # For TabExpansion.ps1
# this requires latest TabExpansion.ps1 in a same directory
function Get-PipeLineObject {
$i = -2
$property = $null
do {
$str = $line.Split("|")
# extract the command name from the string
# first split the string into statements and pipeline elements
... |
PowerShellCorpus/PoshCode/PowerShell Talk Chickens.ps1 | PowerShell Talk Chickens.ps1 | #The PowerShell Talk
#Virtualization Congress 2009
#
#The Chicken Counter Script
#Get our cretendials
#More on credential stores: http://professionalvmware.com/2009/04/09/posh-article-of-the-week-secure-credential-storage/
$credentials = Get-VICredentialStoreItem -File "c:\\scripts\\really_secure_file.xml"
... |
PowerShellCorpus/PoshCode/Set-PowerGUIWelcomePage_3.ps1 | Set-PowerGUIWelcomePage_3.ps1 | ########################################################
# Modifies the default PowerGUI admin console
# welcome screen to the mht file you supply
# Details available at:
# http://dmitrysotnikov.wordpress.com/2009/02/11/rebranding-powergui-console/
########################################################
# Usage... |
PowerShellCorpus/PoshCode/CreateSite_tmp.ps1 | CreateSite_tmp.ps1 | # the order of the set custom WSP template
# Список необходимого для использования личн
... |
PowerShellCorpus/PoshCode/New-SelfSignedCertificat.ps1 | New-SelfSignedCertificat.ps1 | ##############################################################################\n##\n## New-SelfSignedCertificate\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... |
PowerShellCorpus/PoshCode/Set-OCSUser_1.ps1 | Set-OCSUser_1.ps1 | ###########################################################################"
#
# NAME: Set-OCSUser.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: Requires Quest AD cmdlets. This script sets Active Directory user attributes for Microsoft Office Communications Server 2007.
# ... |
PowerShellCorpus/PoshCode/viewAllTemplate.ps1 | viewAllTemplate.ps1 | <# view all template wsp on custom site url
based on
http://www.danielbrown.id.au/Lists/Posts/Post.aspx?ID=74
#>
$site = Get-SPSite "http://spf"
$web = $site.OpenWeb();
foreach($lang in $web.RegionalSettings.InstalledLanguages)
{
Write-Host "Displaying Sites for Langauge: ... |
PowerShellCorpus/PoshCode/ConvertTo-Hex_1.ps1 | ConvertTo-Hex_1.ps1 | # Ported from C# technique found here: http://forums.asp.net/p/1298956/2529558.aspx
param ( [string]$SidString )
# Create SID .NET object using SID string provided
$sid = New-Object system.Security.Principal.SecurityIdentifier $sidstring
# Create a byte array of the proper length
$sidBytes = New-Object byte[] ... |
PowerShellCorpus/PoshCode/Pastebin Functions.ps1 | Pastebin Functions.ps1 | ## Send-Paste (aka sprunge for Pastebin)
##############################################################################################################
## Uploads code to any pastebin.com based pastebin site and returns the url for you.
################################################################################... |
PowerShellCorpus/PoshCode/PowerChart _1.5.ps1 | PowerChart _1.5.ps1 | function New-PowerChart() {
[CmdletBinding(DefaultParameterSetName='DataTemplate')]
param(
[Parameter(Position=0, Mandatory=$true)]
[ValidateSet("Area","Bar","Bubble","Column","Line","Pie","Scatter")]
[String[]]
${ChartType}
,
[Parameter(Position=1, Mandatory=$true, HelpMessage='The data for... |
PowerShellCorpus/PoshCode/Get-ADGroupMembers_3.ps1 | Get-ADGroupMembers_3.ps1 | Function Get-ADGroupMembers
{
<#
.SYNOPSIS
Return a collection of users in an ActiveDirectory group.
.DESCRIPTION
This function returns an object that contains all the properties of a user object. This function
works for small groups as well as groups in ex... |
PowerShellCorpus/PoshCode/New-CodeSigningCertifica.ps1 | New-CodeSigningCertifica.ps1 | #####################################################################
# New-CodeSigningCertificate.ps1
# Version 1.0
#
# Creates new self-signed code signing certificate and installs it to
# current user's personal store. Supports Windows XP and higher.
#
# Initially script was developed for Quest PowerGUI Scrip... |
PowerShellCorpus/PoshCode/Write-IseFile.ps1 | Write-IseFile.ps1 | function Write-IseFile($file, $msg)
{
$Editor = $file.Editor
$Editor.SetCaretPosition($Editor.LineCount, 1)
$Editor.InsertText(($msg + "`r`n"))
}
|
PowerShellCorpus/PoshCode/Get-Gender_1.ps1 | Get-Gender_1.ps1 | ## This script serves three purposes:
## 1) You can look up whether a name is masculine or feminine
## -- even for foreign names.
## 2) It demonstrates the use of the HttpRest functions
## 3) It demonstrates memory-caching:
## how to write a SCRIPT ...
## that becomes a FUNCTION the first time you use it... |
PowerShellCorpus/PoshCode/628b551c-7932-48ee-843d-243be07d7546.ps1 | 628b551c-7932-48ee-843d-243be07d7546.ps1 | function Set-Encoding{
<#
.Synopsis
Takes a Script file or any other text file into memory
and Re-Encodes it in the format specified.
.Parameter FilePath
The path to the file to be re-encoded.
.Parameter Unicode
Outputs the file in Unicode format.
.Parameter UTF7
Outputs the file in UTF7 format.... |
PowerShellCorpus/PoshCode/ShowUI Clock 5.ps1 | ShowUI Clock 5.ps1 | New-UIWidget {
Grid {
$shadow = DropShadowEffect -ShadowDepth 0 -BlurRadius 5 -Direction 0
Ellipse -Name Hour -Fill Transparent -Stroke Black -StrokeThickness 100 -Width 350 -Height 350 -StrokeDashArray 7.85,7.85 -RenderTransformOrigin "0.5,0.5" -RenderTransform { RotateTransform -Angle -90 }
... |
PowerShellCorpus/PoshCode/POC-adding custom PS job_1.ps1 | POC-adding custom PS job_1.ps1 | #this is just a quite proof of concept, totally useless in of itself, with functions not fleshed out
function get-jobrepository
{
[CmdletBinding()]
param()
$pscmdlet.JobRepository
}
function add-job
{
[CmdletBinding()]
param($job)
$pscmdlet.JobRepository.add($job)
}
$src = @"
using System;
using Sy... |
PowerShellCorpus/PoshCode/Move-FileSafely.ps1 | Move-FileSafely.ps1 | function global:Move-FileSafely {
#.Synopsis
# Moves files and folders from $source folder to $destination
#.Description
# Moves files from $source to $destination but if they already exist, it puts them in a parallel $BackupCopies folder instead
#.Parameter Source
# The path to the source directory
#.Parame... |
PowerShellCorpus/PoshCode/Cluster Windows.ps1 | Cluster Windows.ps1 | #Comprobacion del estado de los clusters#
#########################################
# Add Exchange Admin module
If ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null)
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
}
#Fichero donde estan los nombres de los cluster
$activos= ... |
PowerShellCorpus/PoshCode/9db524e2-1659-493b-ad36-3624e7796a76.ps1 | 9db524e2-1659-493b-ad36-3624e7796a76.ps1 | ## Simplest RSS Reader\n####################################################################################################\n## Save this file as Start-RssReader.ps1\n## Run it like:\n## .\\Start-RssReader "http://feeds.feedburner.com/powerscripting", "http://HuddledMasses.org/feed"\n## And then:\n## Get-RSS ... |
PowerShellCorpus/PoshCode/push-module function v2 .ps1 | push-module function v2 .ps1 | # v2.0
function Push-Module {
param(
[parameter(position=0, mandatory=$true)]
[validatenotnullorempty()]
[string]$ModuleName
)
# find out what this module exports (and therefore what it overwrites)
$metadata = new-module -ascustomobject {
param([string]$M... |
PowerShellCorpus/PoshCode/Get Twitter RSS Feed_5.ps1 | Get Twitter RSS Feed_5.ps1 | param ([String] $ScreenName)
$client = New-Object System.Net.WebClient
$idUrl = "https://api.twitter.com/1/users/show.json?screen_name=$ScreenName"
$data = $client.DownloadString($idUrl)
$start = 0
$findStr = '"id":'
do {
$start = $data.IndexOf($findStr, $start + 1)
if ($start -gt 0) {
$s... |
PowerShellCorpus/PoshCode/Get-HtmlHelp 3.0.ps1 | Get-HtmlHelp 3.0.ps1 | ## Get-HtmlHelp - by Joel Bennett
## version 3.0
#####################################################################
## Cool Example, using ShowUI:
## Import-Module HtmlHelp
## Import-Module ShowUI
## function Show-Help { [CmdletBinding()]param([String]$Name)
## Window { WebBrowser -Name wb } ... |
PowerShellCorpus/PoshCode/WPFDiskSpace_1.ps1 | WPFDiskSpace_1.ps1 | #.Example
# Get-WmiObject -computername Z002 Win32_LogicalDisk -filter "DriveType=3" | New-DiskSpace
#.Note
# Requires ShowUI 1.1 and Visifire (You must use Add-UIModule on the Visifire dll and then import it)
function New-DiskSpace {
param([Parameter(ValueFromPipeline=$true)]$InputObject)
begin {
$cha... |
PowerShellCorpus/PoshCode/vibackup linux script.ps1 | vibackup linux script.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/Findup_6.ps1 | Findup_6.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/BufferBox 3.6.ps1 | BufferBox 3.6.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 inspiration t... |
PowerShellCorpus/PoshCode/disable local users 2k08.ps1 | disable local users 2k08.ps1 | ##################################################################################
#
# Script name: Set-LocalAccount.ps1
# Author: niklas.goude@zipper.se
# Homepage: www.powershell.nu
# http://www.powershell.nu/wp-content/uploads/2009/07/set-localaccount.ps1
# start script - .\\set-localaccount.ps1 -D... |
PowerShellCorpus/PoshCode/Roll-Dice.ps1 | Roll-Dice.ps1 | # Roll-Dice.ps1
# Cody Bunch
# ProfessionalVMware.com
Begin {
$rand = New-Object System.Random
$dice = $rand.next(1,3)
}
Process {
if ( $_ -isnot [VMware.VimAutomation.Client20.ManagedObjectBaseImpl.SnapshotImpl] ) { continue }
if ($dice > 1) {
$_ | Remove-Snapshot -Confirm:$false
Write-Host "$_... |
PowerShellCorpus/PoshCode/Get-DellWarranty.ps1 | Get-DellWarranty.ps1 | function Get-DellWarranty {
<#
.Synopsis
Provides warranty information for one or more Dell service tags.
.Description
Queries the Dell Website for a list of service tags and returns the warranty information as a custom object.
If a service tag has multiple warranties, they are... |
PowerShellCorpus/PoshCode/finddupe_12.ps1 | finddupe_12.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/SharePoint UserID grab.ps1 | SharePoint UserID grab.ps1 |
## .\\SharePoint_Users_Read.ps1 "http://some.urlname.com/" "User Information List" ""
## .\\SharePoint_Users_Read.ps1 "http://some.urlname.com/" "User Information List" "user, someone"
param(
[string] $rqurdstrPath = $(Throw "--SharePoint Core Path required."), #required parameter
[string] $rqurdstrListName = $... |
PowerShellCorpus/PoshCode/Check Server Health.ps1 | Check Server Health.ps1 | ########################################################
# Created by Brian English
# Brian.English@charlottefl.com
# eddiephoenix@gmail.com
#
# for Charlotte County Government
# No warranty suggested or implied
########################################################
# Purpose: Check Server Service Healt... |
PowerShellCorpus/PoshCode/8480db1c-b0f9-4a82-aa9a-17edc18cae00.ps1 | 8480db1c-b0f9-4a82-aa9a-17edc18cae00.ps1 | <#
Author: Matt Schmitt
Date: 11/29/12
Version: 1.0
From: USA
Email: ithink2020@gmail.com
Website: http://about.me/schmittmatt
Twitter: @MatthewASchmitt
Description
A script for checking the status of a service on a group of servers, from a list in a file.
#>
$... |
PowerShellCorpus/PoshCode/LookUp-WirelessLocation.ps1 | LookUp-WirelessLocation.ps1 | function LookUp-Location {
param([String] $mac)
$mac = $mac.Replace(":","").Replace("-","")
$wClient = New-Object System.Net.WebClient
$body = "<?xml version='1.0'?><LocationRQ xmlns='http://skyhookwireless.com/wps/2005' version='2.6' street-address-lookup='full'><authentication version='2.0'><simple><username>be... |
PowerShellCorpus/PoshCode/Get-ShortURL.ps1 | Get-ShortURL.ps1 | Function Get-ShortURL {
Param($longURL, $login, $apiKey)
$url = "http://api.bit.ly/shorten?version=2.0.1&format=xml&longUrl=$longURL&login=$login&apiKey=$apikey"
$request = [net.webrequest]::Create($url)
$responseStream = new-object System.IO.StreamReader($request.GetResponse().GetResponseStream())
$response... |
PowerShellCorpus/PoshCode/Show-ColorizedContent.ps.ps1 | Show-ColorizedContent.ps.ps1 | ##############################################################################\n##\n## Show-ColorizedContent\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\nDi... |
PowerShellCorpus/PoshCode/Get-UcsServerVlan.ps1 | Get-UcsServerVlan.ps1 | function Get-UcsServerVlan {
Get-UcsServiceProfile | Foreach-Object {
$sp = $_
$sp | Get-UcsVnic | Foreach-Object {
$vn = $_
$vn | Get-UcsVnicInterface | Foreach-Object {
$output = New-Object psobject –property @{
Server = $sp.Name
... |
PowerShellCorpus/PoshCode/SQLPSX SSIS Demo.ps1 | SQLPSX SSIS Demo.ps1 | #Edit SSIS.psm1 and Comment/Uncomment 2005 or 2008 version of SSIS assembly
#add-type -AssemblyName "Microsoft.SqlServer.ManagedDTS, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
add-type -AssemblyName "Microsoft.SqlServer.ManagedDTS, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd80... |
PowerShellCorpus/PoshCode/Progress Message popup.ps1 | Progress Message popup.ps1 | #Generated Form Function
function ProgressMessage {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
# Generated On: 29/01/2013 11:01 AM
# Generated By: Denis St-Pierre, Ottawa, Canada
#source http://po... |
PowerShellCorpus/PoshCode/Get-ScriptCoverage.ps1 | Get-ScriptCoverage.ps1 | #############################################################################\n##\n## Get-ScriptCoverage\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\nUses c... |
PowerShellCorpus/PoshCode/New-Shortcut.ps1 | New-Shortcut.ps1 | #requires -version 2.0
function New-Shortcut {
<#
.SYNOPSIS
Creates a new shortcut (.lnk file) pointing at the specified file.
.DESCRIPTION
The New-Shortcut script creates a shortcut pointing at the target in the location you specify. You may specify the location as a folder path (which must exist), with a n... |
PowerShellCorpus/PoshCode/695c148f-1099-41a1-abaf-8e0b163f9eff.ps1 | 695c148f-1099-41a1-abaf-8e0b163f9eff.ps1 | #===================================================================================
#
# Filename: AddExecuteInPowerShellToPS1Files.ps1
#
# Author: Nigel Boulton
#
# Version: 1.00
#
# Date: 9 Nov 2008
#
# Mod dates:
#
# Purpose: To add context menu items for .ps1 files in Windows Explorer, to
# allow... |
PowerShellCorpus/PoshCode/Invoke-ComplexScript.ps1 | Invoke-ComplexScript.ps1 | #############################################################################\n##\n## Invoke-ComplexScript\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\nDemo... |
PowerShellCorpus/PoshCode/Windows Startup Script_5.ps1 | Windows Startup Script_5.ps1 | <#======================================================================================
File Name : Startup.ps1
Original Author : Kenneth C. Mazie
:
Description : This is a Windows start-up script with pop-up notification and checks to
: assure things are n... |
PowerShellCorpus/PoshCode/Get-Hostname_1.ps1 | Get-Hostname_1.ps1 | # .SYNOPSIS
# Print the hostname of the system.
# .DESCRIPTION
# This function prints the hostname of the system. You can additionally output the DNS
# domain or the FQDN by using the parameters as described below.
# .PARAMETER Short
# (Default) Print only the computername, i.e. the same value as returned by $env... |
PowerShellCorpus/PoshCode/View-Process_v2.ps1 | View-Process_v2.ps1 | function View-Process(){
param(
[string[]]$ComputerNames,
[string[]]$ProcessNames,
$User
)
if ($User -is [String]){
$Connection = Get-Credential -Credential $User
}
if ($ProcessNames -eq $null){
if ($Connection -eq $null){
foreach ($int1 in $ComputerNames){
$View_Process = gwmi "win32_pro... |
PowerShellCorpus/PoshCode/Run-Query (SharePoint)_1.ps1 | Run-Query (SharePoint)_1.ps1 | function Run-Query($siteUrl, $queryText)
{
[reflection.assembly]::loadwithpartialname("microsoft.sharePOint") | out-null
[reflection.assembly]::loadwithpartialname("microsoft.office.server") | out-null
[reflection.assembly]::loadwithpartialname("microsoft.office.server.search") | out-null
$s = [microsoft.share... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.