full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/GithubGist/NickJosevski_175313_raw_accfad80ded2a017ecbc6f028c4af72d947046ce_ExtractCopyCompressDeploy.ps1 | NickJosevski_175313_raw_accfad80ded2a017ecbc6f028c4af72d947046ce_ExtractCopyCompressDeploy.ps1 | function Select-Folder($message='Select a folder', $path = 0) {
$object = New-Object -comObject Shell.Application
$folder = $object.BrowseForFolder(0, $message, 0, $path)
if ($folder -ne $null) {
$folder.self.Path
}
}
functio... |
PowerShellCorpus/GithubGist/breezhang_1868969_raw_6ee351590937e93d947fd0fec1d9bb73c8a26bdd_Get-HexDump.ps1 | breezhang_1868969_raw_6ee351590937e93d947fd0fec1d9bb73c8a26bdd_Get-HexDump.ps1 | function Get-HexDump($path,$width=10, $bytes=-1)
{
$OFS=""
Get-Content -Encoding byte $path -ReadCount $width `
-totalcount $bytes | Foreach-Object {
$byte = $_
$hex = $byte | Foreach-Object {
" " + ("{0:x}" -f $_).PadLeft(2,"0")}
$char = $byte | Foreach-Object {
if ([char]::IsLetterOrDigit($_))
{ [char... |
PowerShellCorpus/GithubGist/writeameer_1044248_raw_7fa3fde3774cb329786383e7e22aacf89c2ef1bb_InstallRightLink57.ps1 | writeameer_1044248_raw_7fa3fde3774cb329786383e7e22aacf89c2ef1bb_InstallRightLink57.ps1 | ###
# This script installs RightLink on a Windows Server 2008 R2 Server Core machine
function Download-File
{
param (
[parameter(Mandatory=$true)] $url
)
$fileName = $url.Split("/")[-1]
$webClient = New-Object System.Net.WebClient
Write-Host "Downloading: $url"
$webClient.DownloadFile($url,$f... |
PowerShellCorpus/GithubGist/bill-long_230830312b70742321e0_raw_ad3650de9681cb25e5c5df8c6a1befcc9850ea73_Refresh-Path.ps1 | bill-long_230830312b70742321e0_raw_ad3650de9681cb25e5c5df8c6a1befcc9850ea73_Refresh-Path.ps1 | foreach($level in "Machine","User") {
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
# For Path variables, append the new values, if they're not already in there
if($_.Name -match 'Path$') {
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -split ';' | Se... |
PowerShellCorpus/GithubGist/to-taka_3e7a4a9bf6f8b6ffd52f_raw_84cb8bc3e20dbd01cd84e0f13c3ace9f0da9eb99_Get-ADComputer.ps1 | to-taka_3e7a4a9bf6f8b6ffd52f_raw_84cb8bc3e20dbd01cd84e0f13c3ace9f0da9eb99_Get-ADComputer.ps1 | Get-ADComputer -Filter {CN -like "hoge*"} -Properties IPv4Address # change CN condition to target pc name.
|
PowerShellCorpus/GithubGist/belotn_7038878_raw_16ade3a7aa101fe52f6a7b69872ac642697a1f77_get-tsemapconfig.ps1 | belotn_7038878_raw_16ade3a7aa101fe52f6a7b69872ac642697a1f77_get-tsemapconfig.ps1 | $TSEKey="SYSTEM\ControlSet001\Control\Terminal Server\WinStations\RDP-Tcp"
get-XAserver | %{
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$_.ServerName)
$copy = $_
$reg.OpenSubKey($TSEKey).getValueNames() |? { $_ -like 'fDisable*'} |% {
$copy | Add-member -Type NoteProperty -Nam... |
PowerShellCorpus/GithubGist/janikvonrotz_8004176_raw_237a280981c603cf20aea0c069eed2f0f7b04d82_Open-TrueCryptwithKeePass.ps1 | janikvonrotz_8004176_raw_237a280981c603cf20aea0c069eed2f0f7b04d82_Open-TrueCryptwithKeePass.ps1 | & KeePass (Get-Path "$($PSconfigs.Path)..\..\..\..\..\Data\keepass\KeepassData.kdbx") -preselect:((Mount-TrueCyptContainer -Name pc1).Drive + ":\KeePass\keepass_data.key")
Read-Host "`nPress any key to dismount the TrueCrypt drive"
Dismount-TrueCyptContainer -Name pc1
|
PowerShellCorpus/GithubGist/kouphax_1065644_raw_16c5881c94fde58604d4538bb403181a434108d7_default.ps1 | kouphax_1065644_raw_16c5881c94fde58604d4538bb403181a434108d7_default.ps1 | Properties {
}
$framework = '4.0'
Task Default -depends Build
Task Build {
Exec { msbuild .\MySolution.sln /v:quiet }
}
|
PowerShellCorpus/GithubGist/PureKrome_90a1587ea2b6c4f51269_raw_dd9aa4699977586086f08d1e1f34961faf865c62_NuGetPackageAndPublish.ps1 | PureKrome_90a1587ea2b6c4f51269_raw_dd9aa4699977586086f08d1e1f34961faf865c62_NuGetPackageAndPublish.ps1 |
############################################################################
### ###
### NUGET PACKAGE and PUBLISH ###
### ###
######... |
PowerShellCorpus/GithubGist/crancker_5319697_raw_41eeab1f8a123858d9cb6106b28f5263e326a69b_installed.ps1 | crancker_5319697_raw_41eeab1f8a123858d9cb6106b28f5263e326a69b_installed.ps1 | remove-item ./output.txt; $output = get-wmiobject -class Win32_Product | format-table Name, Vendor, Version, caption -auto | Out-String -Width 4096; $output >> ./output.txt; notepad ./output.txt
|
PowerShellCorpus/PoshCode/GetSet-Users.ps1 | GetSet-Users.ps1 | param(
[Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
[alias("Name","ComputerName")][string[]] $Computers = @($env:computername),
#works automagically for domain members or local computer,
#must be set manual for workgroups or forests
[string] $NTDomain = ($env:UserDomain),
... |
PowerShellCorpus/PoshCode/UIAutomation 1.7.ps1 | UIAutomation 1.7.ps1 | ## UI Automation v 1.7 -- REQUIRES the Reflection module (current version: http://poshcode.org/2480 )
##
# WASP 2.0 is getting closer, but this is still just a preview:
# -- a lot of the commands have weird names still because they're being generated ignorantly
# -- eg: Invoke-Toggle.Toggle and Invoke-Invoke.Invo... |
PowerShellCorpus/PoshCode/Enable PS Remoting.ps1 | Enable PS Remoting.ps1 | #Run winrm quickconfig defaults
echo Y | winrm quickconfig
#Run enable psremoting command with defaults
enable-psremoting -force
#Enabled Trusted Hosts for Universial Access
cd wsman:
cd localhost\\client
Set-Item TrustedHosts * -force
restart-Service winrm
echo "Complete"
|
PowerShellCorpus/PoshCode/Get-User_6.ps1 | Get-User_6.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/Send-TcpRequest.ps1 | Send-TcpRequest.ps1 | ##############################################################################\n##\n## Send-TcpRequest\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\nSend a T... |
PowerShellCorpus/PoshCode/Add-Namespace.ps1 | Add-Namespace.ps1 | trap [System.Management.Automation.RuntimeException]
{
$entryException = $_
if ($_.CategoryInfo.Category -eq [System.Management.Automation.ErrorCategory]::InvalidOperation)
{
if ($_.FullyQualifiedErrorId -eq "TypeNotFound")
{
$targetName = $_.CategoryInfo.TargetName
... |
PowerShellCorpus/PoshCode/New-FullDataSet.ps1 | New-FullDataSet.ps1 | ## Generate two dummy datatables in a dataset for testing
$global:dt1 = New-Object system.data.datatable "Times"
$global:dt2 = New-Object system.data.datatable "Properties"
$global:ds = New-Object system.data.dataset "dataset"
$null = $ds.Tables.Add( $dt1 )
$null = $ds.Tables.Add( $dt2 )
$global:cols1 = ls|?{!$... |
PowerShellCorpus/PoshCode/Get Virtual ESXi IP Addr.ps1 | Get Virtual ESXi IP Addr.ps1 | function Get-VirtualEsxiIp {
param($vm)
$tmpFileTemplate = ($env:TEMP + "\\ipdetect-")
$tmpFile = $tmpFileTemplate + (Get-Random) + ".png"
# Take the screenshot.
$view = $vm | Get-View -Property Name
$path = $view.CreateScreenShot()
$path -match "([^/]+/[^/]+$)" | Out-Null
$relativePath = $matches[1]
... |
PowerShellCorpus/PoshCode/finddupe.ps1 | finddupe.ps1 | param($dir = '.')
$matches = 0 # initialize number of matches for summary.
$files = (dir $dir -recurse | ? {$_.psiscontainer -ne $true})
for ($i=0;$i -ne $files.count; $i++) # Cycle thru all files
{
if ($files[$i] -eq $null) {continue}
$md5 = $null
$filecheck = $files[$i]
$files[$i] = $null
fo... |
PowerShellCorpus/PoshCode/Join.ps1 | Join.ps1 | ## Join
## Joins array elements together using a specific string separator
############################################
## Usage:
## $Env:Path = ls | ? {$_.PSIsContainer} | Select -expand FullName | Join ";" -Append $Env:Path
## get-process | select -expand name | join ","
##
function join {
param ... |
PowerShellCorpus/PoshCode/Get-MonthAccountCreated .ps1 | Get-MonthAccountCreated .ps1 | function Get-MonthAccountCreated {
<#
.SYNOPSIS
Gets Account created in given month.
.DESCRIPTION
Gets Account created in given month.
.EXAMPLE
Get-MonthAccountCreated -Month 2 -Year 2012
.EXAMPLE
Get-MonthAccountCreated -Month 10 -Year 2012
.PARAMETER ... |
PowerShellCorpus/PoshCode/get windows product key.ps1 | get windows product key.ps1 | $Reg = [WMIClass]"root\\default:StdRegProv"
$values = [byte[]]($reg.getbinaryvalue(2147483650,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion","DigitalProductId").uvalue)
$lookup = [char[]]("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")
$keyStartIndex = [int]52;
... |
PowerShellCorpus/PoshCode/Autoload Module.ps1 | Autoload Module.ps1 | #Requires -Version 2.0
## Automatically load functions from scripts on-demand, instead of having to dot-source them ahead of time, or reparse them from the script every time.
## Provides significant memory benefits over pre-loading all your functions, and significant performance benefits over using plain scripts. Ca... |
PowerShellCorpus/PoshCode/ScriptMethod Example_1.ps1 | ScriptMethod Example_1.ps1 | $x = New-Object PSObject | Add-Member -MemberType ScriptMethod -Name Test -Value {
.{
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$Message
)
"This is the message: $Message"
} @args
} -PassThru
# You should now cal... |
PowerShellCorpus/PoshCode/Set-Computername_12.ps1 | Set-Computername_12.ps1 | function Set-ComputerName {
param( [switch]$help,
[string]$originalPCName=$(read-host "Please specify the current name of the computer"),
[string]$computerName=$(read-host "Please specify the new name of the computer"))
$usage = "set-ComputerName -originalPCname CurrentName -computername AnewName"
if (... |
PowerShellCorpus/PoshCode/VMware Host Network Info.ps1 | VMware Host Network Info.ps1 | Connect-VIServer MYVISERVER
$filename = "c:\\DetailedNetworkInfo.csv"
Write "Gathering VMHost objects"
$vmhosts = Get-VMHost | Sort Name | Where-Object {$_.State -eq "Connected"} | Get-View
$MyCol = @()
foreach ($vmhost in $vmhosts){
$ESXHost = $vmhost.Name
Write "Collating information for $ESXHost"
$network... |
PowerShellCorpus/PoshCode/VMtoolsUpgrade_2.ps1 | VMtoolsUpgrade_2.ps1 | #####################################################################
#
# Purpose: "Check and upgrade Tools during power cycling"
# Author: David Chung
# Support: IT Infrastructure
# Docs: N/A
#
# Instruction: 1. Create CSV file with list of servers
# 2. Execute script from PowerCLI
# 3. E... |
PowerShellCorpus/PoshCode/ELIM (Event Log IM) 1.1.ps1 | ELIM (Event Log IM) 1.1.ps1 | $ELIMServer = $Env:ComputerName
$ELIMChannel = "ELIM"
$ELIMUser = $Env:UserName
function New-ELIMUser {
#.Synopsis
# Send a message to the ELIM (Event Log Instant Messaging) Log
[CmdletBinding()]
param (
# The Computer whose event logs will be used for instant messaging
[String]$Server = $ELIMServer,... |
PowerShellCorpus/PoshCode/LocalStorage module.ps1 | LocalStorage module.ps1 | if($Args) {
[string]$script:LocalStorageModuleName = $Args[0]
} elseif($LocalStorageModuleName) {
[string]$script:LocalStorageModuleName = $LocalStorageModuleName
} else {
[string]$script:LocalStorageModuleName = "LocalStorage"
}
function Get-LocalStoragePath {
#.Synopsis
# Gets the LocalApplicati... |
PowerShellCorpus/PoshCode/Stop-Pipeline.ps1 | Stop-Pipeline.ps1 | $Wasp = Add-Type -MemberDefinition @'
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
'@ -Passthru
$null = Add-Type -Assembly System.Windows.Forms
filter Stop-Pipeline( [scriptblock]$condition = {$true} ) {
if (& $condition) {
... |
PowerShellCorpus/PoshCode/Select-Grid.ps1 | Select-Grid.ps1 | #requires -version 2.0
### Import the WPF assemblies
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName PresentationCore
Set-PSDebug -Strict
## Select-Grid
## Displays objects in a grid view and returns (only) the selected ones when closed.
###################################################... |
PowerShellCorpus/PoshCode/Edit-Variable.ps1 | Edit-Variable.ps1 | function Edit-Variable {
#.Parameter name
# The name (or path) to the variable to edit.
#.Parameter Environment
# Optional switch to force evaluating the name as an environment variable. You don't need this if you specify the path as env:Path instead of just "Path"
#.Example
# Ed... |
PowerShellCorpus/PoshCode/Get-Snapinfo_1.ps1 | Get-Snapinfo_1.ps1 | Function Get-Snapinfo {
<#
.Synopsis
Get the snapshot info out of a Virtual Machine Managed Entity. Most useful for
reporting!
.PARAMETER VM
VirtualMachine object to scan to extract snapshots from
.PARAMETER VirtualMachineSnapshotTree
used to recursively crawl a ... |
PowerShellCorpus/PoshCode/a706909d-64de-4e36-abce-4f3cc5441fde.ps1 | a706909d-64de-4e36-abce-4f3cc5441fde.ps1 | $vm = get-vm testvm
$ds = $vm | get-datastore
move-vm -VM $vm -Destination (get-vmhost MyDestination) -Datastore $ds
|
PowerShellCorpus/PoshCode/Google Chromium Download_1.ps1 | Google Chromium Download_1.ps1 | <#
.Synopsis
Download Google Chromium if there is a later build.
.Description
Download Google Chromium if there is a later build.
http://poshcode.org/2422
#>
Set-StrictMode -Version Latest
Import-Module bitstransfer
# comment out when not debugging
$VerbosePreferenc... |
PowerShellCorpus/PoshCode/Sync-Time.ps1 | Sync-Time.ps1 | function sync-time(
[string] $server = "clock.psu.edu",
[int] $port = 37)
{
$servertime = get-time -server $server -port $port -set
#leave off -set to just check the remote time
write-host "Server time:" $servertime
write-host "Local time :" $(date)
}
|
PowerShellCorpus/PoshCode/Select-ToString_1.ps1 | Select-ToString_1.ps1 | [CmdletBinding(DefaultParameterSetName='DefaultParameter')]
param(
[Parameter(ValueFromPipeline=$true)]
[System.Management.Automation.PSObject]
${InputObject},
[Parameter(ParameterSetName='DefaultParameter', Position=0)]
[System.String[]]
${Property},
[Parameter(ParameterSetName=... |
PowerShellCorpus/PoshCode/Autoload (beta 6).ps1 | Autoload (beta 6).ps1 | #Requires -Version 2.0
## Version History
## beta 6 - 2010.05.18
## Fixed a bug in output when multiple outputs happen in the END block
## beta 5 - 2010.05.10
## Fixed non-pipeline use using $MyInvocation.ExpectingInput
## beta 4 - 2010.05.10
## I made a few tweaks and bug fixes whil... |
PowerShellCorpus/PoshCode/Asp_2.net-Using httpConext.ps1 | Asp_2.net-Using httpConext.ps1 | Default.aspx
----------------
Partial Class _Default
Inherits System.Web.UI.Page
Dim var1 As String
Dim var2 As String
Protected Sub lnk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnk.Click
Context.Items("Nome") = var1
Context.Items("Email") = var2
Server.Transfer("pagina3.as... |
PowerShellCorpus/PoshCode/Spin-Busy_2.ps1 | Spin-Busy_2.ps1 | ## Spin-Busy displays a "spinning" character with each step reflecting a single pipeline object being passed.
## The current cursor position, fg/bg colors, screen width, etc. can be specified or automatically detected.
##
## This is *very* loosly adapted from Out-Working by Joel Bennett (http://powershellcentral.com... |
PowerShellCorpus/PoshCode/Set-PowerGUIWelcomePage_1.ps1 | Set-PowerGUIWelcomePage_1.ps1 | ########################################################
# Modifies the default PowerGUI admin console
# welcome screen to the mht file you supply
# Details available at:
# http://dmitrysotnikov.wordpress.com/2009/02/11/rebranding-powergui-consolerebranding-powergui-console/
######################################... |
PowerShellCorpus/PoshCode/Hex2Dec_6.ps1 | Hex2Dec_6.ps1 | <!DOCTYPE html>
<html>
<head>
<title>He2Dec</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript">
var num = {
hex2dec : function(n) {
return Number(n) ? Number(n) : 'Wrong data type';
},
... |
PowerShellCorpus/PoshCode/Write-Sitemap.ps1 | Write-Sitemap.ps1 | ####################################################################################################
## Write-Sitemap.ps1
##
## Generates a basic Sitemap for your website, based on a list of locations / products or whatever,
## (depending on your requirements). Can easily be extended to create more complex Sitemaps... |
PowerShellCorpus/PoshCode/New-Password.ps1 | New-Password.ps1 | #.Synopsis
# Generate pseudo-random passwords based on templates
#
#.Parameter Template
# The template for the password you want to generate. This defines which types of characters are generated for each character in the password. The valid template characters are:
# * * - any character: a-z, A-Z, 0-9 + punctua... |
PowerShellCorpus/PoshCode/Networker - Delete ssids.ps1 | Networker - Delete ssids.ps1 |
Write-Host ""
Write-Host "This is dangerous - beware!"
Write-Host "Type: delssids client.domain.com to DELETE ALL it's SAVESETS!!"
function delssids {
## warning - no checks on first arg, security hole! ;)
$client = $args[0]
$ssids = (mminfo -av -q "client=$client" -r ssid)
$ssids | ForEach-Obj... |
PowerShellCorpus/PoshCode/New-PrintJob.ps1 | New-PrintJob.ps1 | <#
.SYNOPSIS
Log a print job to a file.
.DESCRIPTION
This script works in conjunction with an Event Trigger on the PrintService
event on our print servers. This script queries the Microsoft-Windows-PrintService/Operational
log for EventID 307, and returns the drive letter f... |
PowerShellCorpus/PoshCode/Sort-Random.ps1 | Sort-Random.ps1 | ## Sort-Random.ps1
## Shuffle pipeline input into a random order...
## Note that, as with any Sort- function, this is a natural holdup in your pipeline
begin {
$list = @()
}
process {
$list += $_
}
end {
$r = new-object Random
1..$list.Count | % { $list[$r.Next(0,$list.Count-1)] }
}
## There's ... |
PowerShellCorpus/PoshCode/Get-StringRange.ps1 | Get-StringRange.ps1 | function Get-StringRange ( $Start, $End ) {
[char[]]( [int][char]$Start..[int][char]$End )
}
|
PowerShellCorpus/PoshCode/ConvertTo-DN.ps1 | ConvertTo-DN.ps1 | #Author: Glenn Sizemore glnsize@get-admin.com
#
#Purpose: Convert a DN to a conicalname, and back again.
#
#Example: PS > ConvertFrom-Canonical 'get-admin.local/test/test1/Sizemore, Glenn E'
# CN=Sizemore\\, Glenn E,OU=test1,OU=test,DC=getadmin,DC=local
# PS > ConvertFrom-DN 'CN=Sizemore\\, Glenn E,OU=test... |
PowerShellCorpus/PoshCode/NTFS ACLs Folder Tree_5.ps1 | NTFS ACLs Folder Tree_5.ps1 | #######################################
# TITLE: listACL.ps1 #
# AUTHOR: Santiago Fernandez Muñoz #
# #
# DESC: This script generate a HTML #
# report show all ACLs asociated with #
# a Folder tree structure starting in #
# root specified by the user... |
PowerShellCorpus/PoshCode/Set-Computername_9.ps1 | Set-Computername_9.ps1 | function Set-ComputerName {
param( [switch]$help,
[string]$originalPCName=$(read-host "Please specify the current name of the computer"),
[string]$computerName=$(read-host "Please specify the new name of the computer"))
$usage = "set-ComputerName -originalPCname CurrentName -computername AnewName"
if (... |
PowerShellCorpus/PoshCode/Send SNMP trap.ps1 | Send SNMP trap.ps1 | Param ( $DestinationHost )
Add-Type -Path "C:\\Program Files\\LeXtudio Software\\sharpsnmplib.dll"
Add-Type -Path "C:\\Program Files\\LeXtudio Software\\SharpSnmpLib.Controls.dll"
$manager = [system.Net.Dns]::Resolve( $DestinationHost ).AddressList[0]
$TrapDest = New-Object Net.IPEndPoint( $manager, 162 )
[Lextm... |
PowerShellCorpus/PoshCode/Audit iPhone Users.ps1 | Audit iPhone Users.ps1 | #Created by P. Sukus
#Name: iPhone users syncing through OWA audit
#set the timeframe to audit in days
$Daysold = 1
$Date = (get-date).adddays(-$daysold)
$servers = "server1", "server2", "server3"
foreach ($s in $servers)
{
Write-host -ForegroundColor Blue "Checking server $s for files from the last ... |
PowerShellCorpus/PoshCode/b8e330a7-320a-4ae1-8797-9fb1195bfce3.ps1 | b8e330a7-320a-4ae1-8797-9fb1195bfce3.ps1 | param($sqlserver, $filepath)
#Note: Uses Changeset 59378 or higher of SQLPSX SQLServer module http://sqlpsx.codeplex.com/SourceControl/changeset/view/58378#564810
#Added FileListOnly option to Invoke-SqlRestore. The option will be included in releases after 2.3.1
import-module sqlserver -force
$server = get... |
PowerShellCorpus/PoshCode/Create-SCCMCollection_1.ps1 | Create-SCCMCollection_1.ps1 | function Create-SCCMCollection
{
param($Server = $Env:ComputerName, $Name, $Site, $ParentCollectionID = "COLLROOT")
$ColClass = [WMIClass]"\\\\$Server\\Root\\SMS\\Site_$($Site):SMS_Collection"
$Col = $ColClass.PSBase.CreateInstance()
$Col.Name = $Name
$Col.OwnedByThisSite = $True
$Col.Comment = "Collection $Na... |
PowerShellCorpus/PoshCode/Export-PSCredential_2.ps1 | Export-PSCredential_2.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/f5a3c50b-0ede-4fca-ae08-d97b3e9694f1.ps1 | f5a3c50b-0ede-4fca-ae08-d97b3e9694f1.ps1 |
function Start-ISE ()
{
<#
.synopsis
Load some file into ISE
.Description
Load some file into ISE
.Parameter fileObjOrFileName
file to be loaded
.ReturnValue
$null
.Notes
Author: bernd kriszio
e-mail: bkriszio@googlemail.com
... |
PowerShellCorpus/PoshCode/Clear-XCAttributes_1.ps1 | Clear-XCAttributes_1.ps1 | param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()] $User,
[switch]$ClearXCAttributes
)
begin{
$Global:LegacyXCUsers = @()
# attributes to be nulled according to:
# http://blogs.technet.com/b/exchange/archive/2006/10/13/3395089.aspx
$XCattributes=@(
"adminDisplayName","altRecip... |
PowerShellCorpus/PoshCode/Get-SiSReport_3.ps1 | Get-SiSReport_3.ps1 | Function Get-SiSReport
{
<#
.SYNOPSIS
Get the overall SIS usage information.
.DESCRIPTION
This function uses the sisadmin command to get the usage
information for a SIS enabled drive.
.PARAMETER SisDisk
The drive letter of a disk that ... |
PowerShellCorpus/PoshCode/Get-UserLogonLogoffScrip_1.ps1 | Get-UserLogonLogoffScrip_1.ps1 | ##############################################################################
##
## Get-UserLogonLogoffScript
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################
<#
.SYNOPSIS
... |
PowerShellCorpus/PoshCode/File encoding no BOM.ps1 | File encoding no BOM.ps1 | #region Function: Get-DTWFileEncoding
<#
.SYNOPSIS
Returns the encoding type of the file
.DESCRIPTION
Returns the encoding type of the file. It first attempts to determine the
encoding by detecting the Byte Order Marker using Lee Holmes' algorithm
(http://poshcode.org/2153). However, if the file does not ha... |
PowerShellCorpus/PoshCode/qwinsta.ps1 | qwinsta.ps1 | param (
$ComputerName #(Read-Host -Prompt "Enter a computer name")
)
if($ComputerName -eq $null) {
$c = qwinsta 2>&1 | where {$_.gettype().equals([string]) }
} else {
$c = psexec "\\\\$ComputerName" -s qwinsta 2>&1 | where {$_.gettype().equals([string]) }
}
$starters = New-Object psobject -Propert... |
PowerShellCorpus/PoshCode/LetterDiamondOneliner v_4.ps1 | LetterDiamondOneliner v_4.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
# trimmed to... |
PowerShellCorpus/PoshCode/AJAX Scrape.ps1 | AJAX Scrape.ps1 | ## scraping method for ajax driven websites. in this example, google marketplace is the target.
## requires: watin, htmlagilitypack
## http://watin.org/
## http://htmlagilitypack.codeplex.com/
## this scripts directs watin to gunbros and angry birds product pages and htmlagility is used to scrape user revie... |
PowerShellCorpus/PoshCode/Get-Snapinfo.ps1 | Get-Snapinfo.ps1 | Function Get-Snapinfo {
<#
.Synopsis
Get the snapshot info out of a Virtual Machine Managed Entity. Most useful for
reporting!
.PARAMETER VM
VirtualMachine object to scan to abstract snapshots from
.PARAMETER VirtualMachineSnapshotTree
used to recursivley crawl a... |
PowerShellCorpus/PoshCode/dc5f3df6-1aa2-4d34-abf2-d113722bce02.ps1 | dc5f3df6-1aa2-4d34-abf2-d113722bce02.ps1 | ################################################################################
# Get-GprsTime.ps1(V 1006A)
# Check the total connect time of any GPRS devices from a specified date.
# Use the -Detail switch for some extra information if desired. A default value
# can be set with the -Monthly switch but can... |
PowerShellCorpus/PoshCode/Remove-LocalProfile.ps1 | Remove-LocalProfile.ps1 | <#
.SYNOPSIS
Interactive menu that allows a user to connect to a local or remote computer and remove a local profile.
.DESCRIPTION
Presents an interactive menu for user to first make a connection to a remote or local machine. After making connection to the machine,
the user is presented with... |
PowerShellCorpus/PoshCode/Get-ActiveRules (SCOM).ps1 | Get-ActiveRules (SCOM).ps1 | ## Get-ActiveRules grabs the workflows running on the specified server
## Author: Jeremy D. Pavleck - Jeremy@Pavleck.NET
## Requires: The Microsoft.SystemCenter.Internal.Tasks.mp on the SP1 CD
## Notes: You can find this task inside the console by going to monitoring, computers and under "Windows Computer Tasks" run... |
PowerShellCorpus/PoshCode/Move-VMTemplate.ps1 | Move-VMTemplate.ps1 | #requires -pssnapin VMware.VimAutomation.Core -version 1.0
# Author: Glenn Sizemore
# URL: http`://get-admin.com/blog/?p=47
# Purpose: Move VMware templates
#
# Usage: move-VMTemplate -targetpool "pool1" -targethost "ESX1.localdomain.local"
# Will move Every Template in VIVC to ESX1.
#
# move-... |
PowerShellCorpus/PoshCode/chkhash_28.ps1 | chkhash_28.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/Speech Recognition 2.ps1 | Speech Recognition 2.ps1 | $null = [Reflection.Assembly]::LoadWithPartialName("System.Speech")
## Create the two main objects we need for speech recognition and synthesis
if(!$Global:SpeechModuleListener){ ## For XP's sake, don't create them twice...
$Global:SpeechModuleSpeaker = new-object System.Speech.Synthesis.SpeechSynthesizer
$... |
PowerShellCorpus/PoshCode/Backup exchange 2007.ps1 | Backup exchange 2007.ps1 | #######################################################################################
#Backup Exchange 2007
#Fecha: 14/01/2012
#Pedro Genil
#Realizamos un backup de los SG del mailbox
#Se realizara de todos un incremental, y un full del que lleve X dias sin hacerse
#############################################... |
PowerShellCorpus/PoshCode/Set-IPConfig.ps1 | Set-IPConfig.ps1 | # script parameters
param(
[string[]] $Computers = $env:computername,
[switch] $ChangeSettings,
[switch] $EnableDHCP
)
# check for Admin rights
if ($ChangeSettings -or $EnableDHCP){
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.... |
PowerShellCorpus/PoshCode/Get-HelpInfo - PS V3.ps1 | Get-HelpInfo - PS V3.ps1 | #requires -version 3
function Get-HelpInfo {
write-progress -id 1 -Activity "Get-HelpInfo" -Status "Getting remote version table..."
# could cache this
$remote = & {
$html = invoke-webrequest http://technet.microsoft.com/en-us/windowsserver/jj662920
$html.ParsedHtml.getElementsBy... |
PowerShellCorpus/PoshCode/Get-ProcessProfile.ps1 | Get-ProcessProfile.ps1 | ##############################################################################
##
## Get-ProcessProfile
##
##############################################################################
<#
.SYNOPSIS
Uses cdb.exe from the Debugging Tools for Windows to create a sample-based
profile of .NET or native applic... |
PowerShellCorpus/PoshCode/Set-dvSwitch.ps1 | Set-dvSwitch.ps1 | Function Set-dvSwitch {
param($vmName,$dvPG) # the two parameters.
$nic = "Network adapter 1" # change this line if you want to change network adapter 2
# Find the NIC
$vm = Get-VM $vmName | Get-View
foreach($tempdev in $vm.Config.Hardware.Device){
if($tempdev.DeviceInfo.Label -eq $nic){
$tgtdev = ... |
PowerShellCorpus/PoshCode/Create-Printers.ps1 | Create-Printers.ps1 | ###########################################################################"
#
# NAME: Create-Printers.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
# BLOG: http://blog.powershell.no
#
# COMMENT: Simple script to bulk-create printers on a print-server. Printers are imported from a csv-file.... |
PowerShellCorpus/PoshCode/Get-HtmlHelp_1.ps1 | Get-HtmlHelp_1.ps1 | Hello
I contact you a few weeks ago to inquire as to the possibility of sponsoring guest posts on your website: http://huddledmasses.org. I wanted to follow up again to see if there was any interest.
We will research and write quality unique content and pay to have it published to your readers. No spam, and no ... |
PowerShellCorpus/PoshCode/CertMgmt pack_1.ps1 | CertMgmt pack_1.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/Rename NICs.ps1 | Rename NICs.ps1 | $Shell = New-Object -com shell.application
$NetCons = $Shell.Namespace(0x31)
$NetCons.Items() |
where {$_.Name -like 'Local Area Connection*'} |
foreach{$AdapName=$_.Name; get-WmiObject -class Win32_NetworkAdapter |
where-Object {$_.NetConnectionID -eq $AdapName} |
foreach {$MAC=$_.MacAddress}
... |
PowerShellCorpus/PoshCode/Compare Table & DataRow_2.ps1 | Compare Table & DataRow_2.ps1 | function Compare-DataRow
{
param( $a, $b)
# @bernd_k http://pauerschell.blogspot.com/
$diff = ''
$a_columncount = $a.Table.columns.count
$b_columncount = $b.Table.columns.count
if ( $a_columncount -ne $b_columncount)
{
Write-host "Tables have different numbe... |
PowerShellCorpus/PoshCode/XC_SMTPFunctions.ps1 | XC_SMTPFunctions.ps1 | param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()][string[]]$Mailboxes = @(),
[string] $Regex = "domain\\.local$|^CCMAIL|^MS:COMPREGION",
$SMTPdomains = @("domain.com","sub.domain.com"),
$Delimiter = "|",
$OutputLog = "C:\\Projects\\XC\\smtpadresses.csv",
[switch] $Output,
[switch... |
PowerShellCorpus/PoshCode/SqlProxy_7.psm1.ps1 | SqlProxy_7.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/INICIAR-RDP_1.ps1 | INICIAR-RDP_1.ps1 | ########################################################################################################################
# NAME
# Start-RDP
#
# SYNOPSIS
# Opens a remote desktop connection to another computer.
#
# SYNTAX
# Start-RDP [[-Server] <string>] [[-Width] <int>] [[-Height] <int>]
# Star... |
PowerShellCorpus/PoshCode/Remove diacritics_1.ps1 | Remove diacritics_1.ps1 | ### Grťgory Schiro, 2009
### <summary>
### Removes diacritics from string.
### </summary>
### <param name="String">String containing diacritics</param>
function Remove-Diacritics([string]$String)
{
$objD = $String.Normalize([Text.NormalizationForm]::FormD)
$sb = New-Object Text.StringBuilder
fo... |
PowerShellCorpus/PoshCode/group-byobject_2.ps1 | group-byobject_2.ps1 | function Group-ByObject {
#.Synopsis
# Groups by a set of properties, returning objects
#.Description
# A wrapper for the built-in Group-Object cmdlet which returns one of the original objects (with separate properties for each property used to group) rather than a simple string representation as the "name" of the ... |
PowerShellCorpus/PoshCode/VMWare Quick Migration_4.ps1 | VMWare Quick Migration_4.ps1 | #########################################
#Name: VMWare Quick Migration Function
#Author: Justin Grote <jgrote NOSPAMAT enpointe DOT com>
#Credit: Inspired by Mike DiPetrillo's Quick Migration Script: http://www.mikedipetrillo.com/mikedvirtualization/2008/10/quick-migration-for-vmware-the-power-of-powershell.html
#... |
PowerShellCorpus/PoshCode/Get-Parameter_17.ps1 | Get-Parameter_17.ps1 | param (
$Cmdlet,
[switch]$ShowCommon,
[switch]$Full
)
$command = Get-Command $Cmdlet -ea silentlycontinue
# resolve aliases (an alias can point to another alias)
while ($command.CommandType -eq "Alias") {
$command = Get-Command ($command.definition)
}
if (-not $command) { return }
foreach ($p... |
PowerShellCorpus/PoshCode/Xml Module 6.6.ps1 | Xml Module 6.6.ps1 | #requires -version 2.0
# Improves over the built-in Select-XML by leveraging Remove-XmlNamespace http`://poshcode.org/1492
# to provide a -RemoveNamespace parameter -- if it's supplied, all of the namespace declarations
# and prefixes are removed from all XML nodes (by an XSL transform) before searching.
# IMP... |
PowerShellCorpus/PoshCode/Set-IPConfigv_1.ps1 | Set-IPConfigv_1.ps1 | # script parameters
param(
[Parameter(Position=0,ValueFromPipeline=$True)]
[ValidateNotNullorEmpty()][string[]] $Computers = $env:computername,
[switch] $ChangeSettings,
[switch] $EnableDHCP,
[switch] $IpRelease
)
# script variables
$nl = [Environment]::NewLine
$Domain = "domain.local"
$DNSSuffix = @("doma... |
PowerShellCorpus/PoshCode/CIM SMI-S Query Library.ps1 | CIM SMI-S Query Library.ps1 | function cim-ei {
<#
.SYNOPSIS
Enumerate Instances of a class on a CIMOM via CIM-XML interface
.DESCRIPTION
Primary use case of this function is to gather inventory and performance information from IT
infrastructure assets. The inventory information feeds into capacity planning, troubleshooting,
... |
PowerShellCorpus/PoshCode/Patch-VMHost_1.ps1 | Patch-VMHost_1.ps1 |
Add-PSSnapin "VMware.VimAutomation.Core"
Add-PSSnapIn "VMware.VumAutomation"
# Connect to vCenter
$VC = Connect-VIServer (Read-Host "Enter vCenter server")
$vumConfig = Get-VumConfig
$EsxHost = Get-Inventory -Name (Read-Host "Enter ESX Host")
$CriticalHost = Get-Baseline -Name "Critical Host Updates"
$N... |
PowerShellCorpus/PoshCode/group-byobject_3.ps1 | group-byobject_3.ps1 | function Group-ByObject {
#.Synopsis
# Groups by a set of properties, returning objects
#.Description
# A wrapper for the built-in Group-Object cmdlet which returns one of the original objects (with separate properties for each property used to group) rather than a simple string representation as the "name" of the ... |
PowerShellCorpus/PoshCode/fb0323a1-dc73-453e-975e-ec2b354c78d1.ps1 | fb0323a1-dc73-453e-975e-ec2b354c78d1.ps1 | # Glenn Sizemore ~ www . Get-Admin . Com
# Example Powershell function to get the NFS Exports from a NetApp Filer
# First you'll need to download the OnTap SDK 3.5 : http://communities.netapp.com/docs/DOC-1365
# within the download your interested in .\\manage-ontap-sdk-3.5\\lib\\DotNet\\ManageOntap.dll
# Next... |
PowerShellCorpus/PoshCode/target.local.ps1 | target.local.ps1 | #alias,addnewemailaddress
import-csv .\\source.csv | foreach {
$user = Get-Mailbox $_.alias
$user.emailAddresses+= $_.addnewemailaddress
$user.primarysmtpaddress = $_.addnewemailaddress
Set-Mailbox $user -emailAddresses $user.emailAddresses
set-Mailbox $user -PrimarySmtpAddress $user.primarysmtpaddress
}
|
PowerShellCorpus/PoshCode/Export-ScreenShot.ps1 | Export-ScreenShot.ps1 | ## Export-Screenshot to take a screenshot and save it to disk
#####################################################################################
## Usage:
## Export-Screenshot sshot.png
## Export-Screenshot screen.jpg (New-Object Drawing.Rectangle 0, 0, 640, 480)
############################################... |
PowerShellCorpus/PoshCode/DHCP Backup_2.ps1 | DHCP Backup_2.ps1 | param (
[Parameter(Position=1)]
$searchBase = "cn=configuration,dc=domain,dc=com",
[Parameter(Position=2)]
$backupDestRoot = "\\\\network\\share\\"
)
Import-Module ActiveDirectory
function Get-OnlineDhcpServers {
param (
[Parameter(Mandatory=$true,Position=1)]
$dhcpSear... |
PowerShellCorpus/PoshCode/TabExpansion_7.ps1 | TabExpansion_7.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.
## Some features(relate to '$_' expansion) require the latest Get-PipelineObject.ps1 in a same diretory. (from http://poshcode.org/author/foo... |
PowerShellCorpus/PoshCode/Backup all ESXi_2.ps1 | Backup all ESXi_2.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/16ca876b7bb7ac8c2f362b_1.ps1 | 16ca876b7bb7ac8c2f362b_1.ps1 | #.Synopsis
# Test the HMAC hash(es) of a file
#.Description
# Takes the HMAC hash of a file using specified algorithm, and optionally, compare it to a baseline hash
#.Example
# Test-Hash npp.5.3.1.Installer.exe -HashFile npp.5.3.1.release.md5
#
# Searches the provided hash file for a line matching the "... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.