full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Set-PSObjectDefaultPrope.ps1 | Set-PSObjectDefaultPrope.ps1 | function Set-PSObjectDefaultProperties {
param(
[PSObject]$Object,
[string[]]$DefaultProperties
)
$name = $Object.PSObject.TypeNames[0]
$xml = "<?xml version='1.0' encoding='utf-8' ?><Types><Type>"
$xml += "<Name>$($name)</Name>"
$xml... |
PowerShellCorpus/PoshCode/Get-Tomorrow.ps1 | Get-Tomorrow.ps1 | ##############################################################################\n## Get-Tomorrow\n##\n## Get the date that represents tomorrow\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n######################################################################... |
PowerShellCorpus/PoshCode/Add-FormatTableIndexPara.ps1 | Add-FormatTableIndexPara.ps1 | ##############################################################################\n##\n## Add-FormatTableIndexParameter\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPS... |
PowerShellCorpus/PoshCode/NTFS Streams 1.0.ps1 | NTFS Streams 1.0.ps1 | #requires -version 2.0
## Version 1.0 - First release outside of the PoshCode module.
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
function Set-DownloadFlag {
<#
.Synopsis
Sets the ZoneTransfer flag which marks a file as being downloaded from the internet.
.Description
Creates a Zone.Id... |
PowerShellCorpus/PoshCode/Start-Encryption_1.ps1 | Start-Encryption_1.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/Stop service and wait_1....ps1 | Stop service and wait_1....ps1 | <#
This script stops the service, then waits for the service to stop before continuing with the reboot/shutdown
The scritp can be pushed to a server/Pc using Group Policy or Registry or run manually.
The shutdown script Registry key is:
HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\State\\Ma... |
PowerShellCorpus/PoshCode/64d622dd-3de1-4904-8512-d2f40cde9914.ps1 | 64d622dd-3de1-4904-8512-d2f40cde9914.ps1 | #This scripts compares the agents that are installed in two zones and
#gives the agents that are not common.
#Usage:
#Compare-Agents.ps1 -server1 RMSServer1.contoso.com -server2 RMSServer2.contoso.com -output c:\\Temp.txt
#RMSServer1 is the one whose agents are to be moved.
param([string] $Server1,$Server2,$outp... |
PowerShellCorpus/PoshCode/Create random strings_1.ps1 | Create random strings_1.ps1 | # ===============================================================
# / Author: Marcus L. Farmer
# / Script: createRandomStrings.ps1
# / Date: 2-04-2009
# / Purpose: generate pseudorandomly generated strings for passwords or other uses
# / Usage: ./createRandomStrings.ps1
# / Reqs.: none... |
PowerShellCorpus/PoshCode/Set-Prompt.ps1 | Set-Prompt.ps1 | # This should go OUTSIDE the prompt function, it doesn't need re-evaluation\n# We're going to calculate a prefix for the window title \n# Our basic title is "PoSh - C:\\Your\\Path\\Here" showing the current path\nif(!$global:WindowTitlePrefix) {\n # But if you're running "elevated" on vista, we want to show that ...\... |
PowerShellCorpus/PoshCode/Get-XamlControlTemplate.ps1 | Get-XamlControlTemplate.ps1 | ## Get-XamlControlTemplate\n## Dump a WPF control's default XAML template\n########################################################################################################################\n## Usage:\n## Get-XamlControlTemplate System.Windows.Navigation.NavigationWindow\n## Get-XamlControlTemplate MenuItem\n## G... |
PowerShellCorpus/PoshCode/Show-ConsoleMenu.ps1 | Show-ConsoleMenu.ps1 | function Show-ConsoleMenu {
#.Synopsis
# Displays a menu in the console and returns the selection
#.Description
# Displays a numbered list in the console, accepts a typed number from the user, and returns it.
#.Example
# ls | Show-ConsoleMenu -Title "Please pick a file to delete:" -Passthru | rm -whatif
#
# ... |
PowerShellCorpus/PoshCode/Local Software Inventory.ps1 | Local Software Inventory.ps1 | # Create a new Excel object using COM
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $True
$Excel.DisplayAlerts = $False
# Counter variable for rows
$intRow = 1
$Excel = $Excel.Workbooks.Add()
$Sheet = $Excel.Worksheets.Item(1)
#Create column headers
$Sheet.Cells.Item($intRow,1) = "So... |
PowerShellCorpus/PoshCode/Thin provisioning with P.ps1 | Thin provisioning with P.ps1 | function ConvertVMDiskToThin($vm, $datastore) {
$vmView = Get-View $vm
$dsView = Get-View $datastore
$relocateSpec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$relocateSpec.Datastore = $dsView.MoRef
$relocateSpec.Transform = "sparse"
$vmView.RelocateVM($relocateSpec, $null)
}
|
PowerShellCorpus/PoshCode/Get-Dirty Extended.ps1 | Get-Dirty Extended.ps1 | ## NAME: Get-Dirty.ps1
## AUTHOR: Barry Morrison
## LASTEDIT: 07/05/2011 16:18:33
<#
.Synopsis
Get's files from today's date. Will also return narrowed results based on keyword
.Description
Get's files from today's date. Will also return narrowed results based on keyword
.Parameter... |
PowerShellCorpus/PoshCode/8c6c6bed-3b96-4711-a7b1-2bce64494698.ps1 | 8c6c6bed-3b96-4711-a7b1-2bce64494698.ps1 | Function Test-Server{
[cmdletBinding()]
param(
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string[]]$ComputerName,
[parameter(Mandatory=$false)]
[switch]$CredSSP,
[Management.Automation.PSCredential] $Credential)
begin{
$total = Get-Date
$results = @()
if($credssp){if(!($credential)){Wri... |
PowerShellCorpus/PoshCode/CommandTranscript.ps1 | CommandTranscript.ps1 | if(!$global:CommandTranscriptPrompt) {
## Record the original prompt so we can put it back if they change their minds...
$global:CommandTranscriptPrompt = ${Function:Prompt}
}
function Start-CommandTranscript {
#.Synopsis
# Start a transcript recording the commands you enter, and optionally, the success ... |
PowerShellCorpus/PoshCode/Transcript sessions.ps1 | Transcript sessions.ps1 | # Create the transcript file and start the transcript
new-item -path ([Environment]::GetFolderPath('MyDocuments')) -name "PowerShell_Transcripts" -type directory -ea "silentlycontinue"
$transcriptFolder = [Environment]::GetFolderPath('MyDocuments') + "\\PowerShell_Transcripts\\"
$filedate = get-date -format yyyyMMdd... |
PowerShellCorpus/PoshCode/Update web.config.ps1 | Update web.config.ps1 | Function Update-WCContents($File,$SearchString,$NewValue){
$Contents = Get-Content -Path $File
$Contents | %{$_.Replace($SearchString,$NewValue)} | Set-Content $File
} # End Update-WCContents Function
|
PowerShellCorpus/PoshCode/ConvertFrom-Property_3.ps1 | ConvertFrom-Property_3.ps1 | function ConvertFrom-PropertyString {
<#
.SYNOPSIS
Converts data from flat or single-level property files into PSObjects
.DESCRIPTION
Converts delimited string data such as .ini files, or the format-list output of PowerShell, into objects
.EXAMPLE
netsh http show sslcert | join-string "`n" |
Conver... |
PowerShellCorpus/PoshCode/Findup.ps1 | Findup.ps1 | using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;
namespace ConsoleApplication1
{
public class FileInfoExt
{
pu... |
PowerShellCorpus/PoshCode/New-XVM_13.ps1 | New-XVM_13.ps1 | #EXAMPLES
<#
New-XVM -ComputerName HYPERVSVR02 -Name "WS2012-TESTSVR01" -SwitchName "External(192.168.1.0/24)" -VhdType NoVHD
New-XVM -ComputerName HYPERVSVR02 -Name "WS2012-TESTSVR02" -SwitchName "External(192.168.1.0/24)" -VhdType ExistingVHD -VhdPath D:\\vhds\\WS2012-TESTSVR02.vhdx
New-XVM -ComputerName HYPERVSV... |
PowerShellCorpus/PoshCode/Set account password_1.ps1 | Set account password_1.ps1 | Function Set-Password {
#requires -version 2.0
<#
.Synopsis
Allows the changing of the local account password on a local or remote machine.
.Description
Allows the changing of the local account password on a local or remote machine.
.Parameter computer
Computer that the password will be changed on... |
PowerShellCorpus/PoshCode/My $Profile.ps1 | My $Profile.ps1 | <#
Set some Variables and start transcript.
$MaximumHistoryCount is used to set the number of commands that are stored in History. Defaults to 64. Maximum 32767.
$Transcript is used to set the path for Start-Transcript. I am logging everthing to my SkyDrive folder, using a file name like: username... |
PowerShellCorpus/PoshCode/Add CounterPaths 2 Mongo.ps1 | Add CounterPaths 2 Mongo.ps1 | <#
.NOTES
AUTHOR: Sunny Chakraborty(sunnyc7@gmail.com)
WEBSITE: http://tekout.wordpress.com
CREATED: 8/20/2012
Requires:
a) PowerShell v2 or better
b) Requires Mongo Official C# driver
https://github.com/mongodb/mongo-csharp-driver/downloads
Tested using 1.5.0.X
.DESCRIPTION
Similar in vein to Add-Event... |
PowerShellCorpus/PoshCode/chkhash_32.ps1 | chkhash_32.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/Add-SVNFile.ps1 | Add-SVNFile.ps1 | None |
PowerShellCorpus/PoshCode/Invoke-SqlCmdExe.ps1 | Invoke-SqlCmdExe.ps1 | <#
.SYNOPSIS
Runs a T-SQL Query and optional outputs results to a file.
.DESCRIPTION
Invoke-SqlCmdExes.ps1 script is a wrapper around sqlcmd.exe to run a T-SQL query or stored procedure and optionally outputs to a file.
.EXAMPLE
PowerShell.exe -File "C:\\Scripts\\Invoke-SqlCmdExe.ps1" -ServerInstance "Z001\\sql1"... |
PowerShellCorpus/PoshCode/Remove-DeadITunesTracks.ps1 | Remove-DeadITunesTracks.ps1 | Clear
$ITunes = New-Object -ComObject iTunes.Application
1..$ITunes.LibraryPlaylist.Tracks.Count | % {
$CurrentTrack = $ITunes.LibraryPlaylist.Tracks.Item($_)
# File Track ??
if ( $CurrentTrack.Kind -eq 1 )
{
if ( ! ([System.IO.File]::Exists($CurrentTrack.Location)) )
{
Write-Host "$($Current... |
PowerShellCorpus/PoshCode/Work-in-progressSPdeploy.ps1 | Work-in-progressSPdeploy.ps1 |
[System.Reflection.Assembly]::Load('Microsoft.Build.Utilities.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | out-null
[System.Reflection.Assembly]::Load('Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c') | out-null
$msbuild = [Microsoft.Build.U... |
PowerShellCorpus/PoshCode/Twitter Module v0.2.1b.ps1 | Twitter Module v0.2.1b.ps1 | <#
<#
Name: Social Media Scripting Framework
Module: Twitter
Version: 0.2 BETA
Date: 2013/02/03
Author: Carlos Veira Lorenzo
RoughRevision: chriskenis
e-mail: cveira [at] thinkinbig [dot] org
blog: thinkinbig.org
twitter: @cveira
facebook: www.facebook.com/cveira
Google+: gplus.to/cveira
LinkedIn: es.linke... |
PowerShellCorpus/PoshCode/Read-HostWithPrompt_1.ps1 | Read-HostWithPrompt_1.ps1 | #############################################################################
##
## Read-HostWithPrompt
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################
<#
.SYNOPSIS
Read ... |
PowerShellCorpus/PoshCode/ConvertFrom-Property_1.ps1 | ConvertFrom-Property_1.ps1 | <#
.SYNOPSIS
Converts data from flat or single-level property files into PSObjects
.DESCRIPTION
Converts delimited string data into objects
.PARAMETER PropertyText
The text to be parsed
.PARAMETER Separator
The value separator string used between name=value pairs. Allows regular expressions.
Def... |
PowerShellCorpus/PoshCode/mklink.ps1 | mklink.ps1 | using System;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
namespace mklink
{
class mklink
{
[DllImport("kernel32.dll")]
static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
static void Main(st... |
PowerShellCorpus/PoshCode/Prompt _for ISE_.ps1 | Prompt _for ISE_.ps1 | # just to know which file is invoked by my profile
write-host "loaded . $($MyInvocation.MyCommand.Path)"
if(!$global:WindowTitlePrefix) {
# But if you're running "elevated" on vista, we want to show that ...
if( ([System.Environment]::OSVersion.Version.Major -gt 5) -and ( # Vista and ...
new-objec... |
PowerShellCorpus/PoshCode/Get-ComputerSession.ps1 | Get-ComputerSession.ps1 | Function Get-ComputerSession {
<#
.SYNOPSIS
Retrieves all user sessions from local or remote server/s
.DESCRIPTION
Retrieves all user sessions from local or remote server/s. Requires query.exe in order to run properly.
.PARAMETER computer
Name of computer/s to run session query against. ... |
PowerShellCorpus/PoshCode/Experimental.IO 1.0.ps1 | Experimental.IO 1.0.ps1 | ## Requires the Experimental.IO "LongPath" library from the BCL team: http://bcl.codeplex.com/
## Compile it against .Net 3.5 (for PowerShell's sake) and place it the module folder with this psm1
if(!("Microsoft.Experimental.IO.LongPathDirectory" -as [type])) {
Add-Type -Path $PSScriptRoot\\Microsoft.Experimental... |
PowerShellCorpus/PoshCode/ConvertTo-Module_1.ps1 | ConvertTo-Module_1.ps1 | function ConvertTo-Module {
<#
.SYNOPSIS
Quickly convert a .NET type's static methods into functions
.DESCRIPTION
Quickly convert a .NET type's static methods into functions.
This function returns a PSModuleInfo, so you should pipe its
output to Import-Module to use the exported f... |
PowerShellCorpus/PoshCode/Get-RemoteRegistryKeyPro.ps1 | Get-RemoteRegistryKeyPro.ps1 | ##############################################################################\n##\n## Get-RemoteRegistryKeyProperty\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPS... |
PowerShellCorpus/PoshCode/Networker - Delete ssids_1.ps1 | Networker - Delete ssids_1.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-Objec... |
PowerShellCorpus/PoshCode/Start-Verify_3.ps1 | Start-Verify_3.ps1 | # Author: Steven Murawski http://www.mindofroot.com
# This script creates two functions (and a helper function). One starts logging all commands entered,
# and the second removes the logging.
# This script is similar to the Start-Transcript, but only logs the command line and not the output.
# Modified to add ... |
PowerShellCorpus/PoshCode/Rollback Policy Module.ps1 | Rollback Policy Module.ps1 | Function Get-RollbackPolicy {
<#
.SYNOPSIS
Retieves the current rollback policy on a local or remote computer
.DESCRIPTION
Retieves the current rollback policy on a local or remote computer
.PARAMETER Computername
The name of the computer or computers to perform the q... |
PowerShellCorpus/PoshCode/PowerShellServer Cmdlet .ps1 | PowerShellServer Cmdlet .ps1 | \n#Global Hashtable to Control all Powershell Server Runspace\nSet-Variable -name '__PSRUNSPACES__' -scope 'global' -value @{} -force\n\nfunction global:New-PowerShellServerRunspace\n{\n param(\n $Credential,\n $ErrorAction='Stop',\n [switch]$Force,\n $Password,\n $Port=22,\n $Server='127.0.0.1',\n $SSHAccept,\n... |
PowerShellCorpus/PoshCode/Set-Computername_8.ps1 | Set-Computername_8.ps1 | function Set-ComputerName {
param( [switch]$help,
[string]$computerName=$(read-host "Please specify the new name of the computer"))
$usage = "set-ComputerName -computername AnewName"
if ($help) {Write-Host $usage;break}
$computer = Get-WmiObject Win32_ComputerSystem
$computer.Rename($computerName)
... |
PowerShellCorpus/PoshCode/PowerBoots Gadgets_1.ps1 | PowerBoots Gadgets_1.ps1 | $gadgetWindow = @{
# Transparency, WindowStyle, and background work together
# to get rid of the standard window's chrome and make the window "irregular" shaped
# that is, the window will be the shape of it's content.
AllowsTransparency = $True
WindowStyle = "None"
Background = "Transparent"
... |
PowerShellCorpus/PoshCode/Get-WebFile _1.6.ps1 | Get-WebFile _1.6.ps1 | ## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.6 - Add -Passthru switch to output TEXT files
## v3.5 - Add -Quiet switch to turn off the progress repo... |
PowerShellCorpus/PoshCode/ScriptTransforms module_1.ps1 | ScriptTransforms module_1.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/tst.ps1 | tst.ps1 | # Follwoing code to install and deploye site
# Parameter Section Start
$languagePack="{1033}" # this line is used to notify the language pack used by the sharepoint server
$path= "D:\\tmp\\ps\\template\\kolam.wsp" # path of the wsp to be read
$feature = "kolamWebTemplate" #Feature Name of the wsp to be activa... |
PowerShellCorpus/PoshCode/FileCop.ps1 | FileCop.ps1 | $nul = "<NULL>"
$sec = "MD5", "SHA1", "SHA256", "SHA384", "SHA512", "RIPEMD160"
##################################################################################################
function Add-RootsTree {
[IO.Directory]::GetLogicalDrives() | % {
$nod = New-Object Windows.Forms.TreeNode
$nod = $tvRoot... |
PowerShellCorpus/PoshCode/Select-ViaGUI_1.ps1 | Select-ViaGUI_1.ps1 | function Select-ViaUI {
#.Synopsis
# Select objects through a visual interface
#.Description
# Uses a graphical interface to select (and pass-through) pipeline objects
# Idea from Lee Holmes (http://www.leeholmes.com/blog)
#.Example
# Get-ChildItem | Select-ViaUI -show | Remove-Item -WhatIf
[OutputT... |
PowerShellCorpus/PoshCode/vProfile.ps1 | vProfile.ps1 | # vProfiler.ps1 : vSphere profiling script
# This script will export recursively all objects and properties of a VI/vSphere entity to a XML file
# Parameters:
# $entityName : the name of the vSphere entity for which the properties should be written to the XML file
# $childShow : Boolean switch, export all children ... |
PowerShellCorpus/PoshCode/Check Exchange2010 queue.ps1 | Check Exchange2010 queue.ps1 | # Script: Exch2010QueueMonitor.ps1
# Purpose: This script can be set as a scheduled task to run every 30minutes and will monitor all exchange 2010 queue's. If a threshold of 10 is met an
# output file with the queue details will be e-mailed to all intended admins listed in the e-mail settings
# Author: Papercl... |
PowerShellCorpus/PoshCode/Get-Parameter_10.ps1 | Get-Parameter_10.ps1 | function Get-Parameter ( $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 }
... |
PowerShellCorpus/PoshCode/Get-Screenshot.ps1 | Get-Screenshot.ps1 | ## Get-Screenshot -- THIS ONE works on PowerShell 1.0 and .Net 2.0 (or better)
############################################################################################################
## Usage:
## Get-Screenshot "C:\\Screencaps\\Screenshot.jpg"
## Get-Screenshot "$pwd\\Screen $(Get-Date -f 'yyyy-MM-dd HH... |
PowerShellCorpus/PoshCode/Custom Speech Commands_2.ps1 | Custom Speech Commands_2.ps1 | #Filename commands.ps1
import-module "G:\\Documents\\Speech Macros\\custom.psm1"
import-module "G:\\Documents\\Speech Macros\\alice.psm1"
Add-SpeechCommands @{
"test command" = { Say $(Respond "3:2,4:0-2") }
" * the percentages * " = { Say $(Percentages) }
" * star date * " = { Say "Current,... |
PowerShellCorpus/PoshCode/Test-VM_2.ps1 | Test-VM_2.ps1 | Function Test-VM
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory=$true,Position=1)]
[string[]]$Name,
[Parameter(Mandatory=$true,Position=2)]
[string[]]$ComputerName
)
Process
{
$results = @()
foreach ($cName in $ComputerName) {
... |
PowerShellCorpus/PoshCode/System Analyst II.ps1 | System Analyst II.ps1 | $strComputer = "PrinterName"
$Ports = get-wmiobject -class "win32_tcpipprinterport" -namespace "root\\CIMV2" -computername $strComputer
$Printers = get-wmiobject -class "Win32_Printer" -namespace "root\\CIMV2" -computername $strComputer
$ports | Select-Object Name,Hostaddress | Set-Variable port
$Printers | Select-... |
PowerShellCorpus/PoshCode/Get-RecurseMember_3.ps1 | Get-RecurseMember_3.ps1 | function Get-RecurseMember {
<#
.Synopsis
Does a recursive search for unique users that are members of an AD group.
.Description
Recursively gets a list of unique users that are members of the specified
group, expanding any groups that are members out into their member users.
Note: Requires the Ques... |
PowerShellCorpus/PoshCode/Convert-StringSID.ps1 | Convert-StringSID.ps1 | function Convert-StringSID {
<#
.Synopsis
Takes a SID string and outputs a Win32_SID object.
.Parameter sidstring
The SID in SDDL format. Example: S-1-5-21-39260824-743453154-142223018-195717
.Description
Takes a SID string and outputs a Win32_SID object.
Note: it also adds an extra property, base64... |
PowerShellCorpus/PoshCode/hugo.ps1 | hugo.ps1 | $choices = [System.Management.Automation.Host.ChoiceDescription[]](
(New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Choose me!"),
(New-Object System.Management.Automation.Host.ChoiceDescription "&No","Pick me!"))
$Answer = $host.ui.PromptForChoice('Caption',"Message",$choices,(1))
Write-... |
PowerShellCorpus/PoshCode/powershell ise config_2.ps1 | powershell ise config_2.ps1 | <configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0" />
<process>
<rollForward enabled="false" />
</process>
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
</run... |
PowerShellCorpus/PoshCode/Convert-StringSID_1.ps1 | Convert-StringSID_1.ps1 | function Convert-StringSID {
<#
.Synopsis
Takes a SID string and outputs a Win32_SID object.
.Parameter sidstring
The SID in SDDL format. Example: S-1-5-21-39260824-743453154-142223018-195717
.Description
Takes a SID string and outputs a Win32_SID object.
Note: it also adds an extra property, base64... |
PowerShellCorpus/PoshCode/10.100.5.32.ps1 | 10.100.5.32.ps1 | function Set-IPAddress {
param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"),
[string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"),
[string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"),
[string]$gateway = $(read-host "Enter... |
PowerShellCorpus/PoshCode/Out-DataTable_3.ps1 | Out-DataTable_3.ps1 | #######################
<#
.SYNOPSIS
Creates a DataTable for an object
.DESCRIPTION
Creates a DataTable based on an objects properties.
.INPUTS
Object
Any object can be piped to Out-DataTable
.OUTPUTS
System.Data.DataTable
.EXAMPLE
$dt = Get-psdrive| Out-DataTable
This example creates a DataTable fr... |
PowerShellCorpus/PoshCode/SpeakToMe.ps1 | SpeakToMe.ps1 | <#
inspired by HelloKitty script and Mike Hays's obsession for Julie Andrews
added voice selection menu, should work for everyone anywhere
interluded speaking by using string array joined with newline
still need to figure out $voiceToUse code, it's working but I don't know why or how
https://github.com/chriskenis/... |
PowerShellCorpus/PoshCode/e0f06189-086f-4d62-a6c3-5a7e1f3ca246.ps1 | e0f06189-086f-4d62-a6c3-5a7e1f3ca246.ps1 | $computers = gc "listofservers.txt"
Get-WmiObject Win32_NetworkAdapterConfiguration -computer $computers -filter "IPEnabled ='true'" | select __Server,IPAddress
|
PowerShellCorpus/PoshCode/Read-HostMasked.ps1 | Read-HostMasked.ps1 | function Read-HostMasked([string]$prompt="Password") {
$password = Read-Host -AsSecureString $prompt;
$BSTR = [System.Runtime.InteropServices.marshal]::SecureStringToBSTR($password);
$password = [System.Runtime.InteropServices.marshal]::PtrToStringAuto($BSTR);
[System.Runtime.InteropServices.Marshal]::Zero... |
PowerShellCorpus/PoshCode/FunctionInfo.types.ps1xm.ps1 | FunctionInfo.types.ps1xm.ps1 | <?xml version="1.0" encoding="utf-8" ?>
<Types>
<Type>
<Name>System.Management.Automation.FunctionInfo</Name>
<Members>
<ScriptProperty>
<Name>Verb</Name>
<GetScriptBlock>
if ($this.Name.Contains("-")) {
$this.Name.Substring(0,$this.Name.Indexof("-"))
} else {
$null
... |
PowerShellCorpus/PoshCode/JSON.ps1 | JSON.ps1 | #requires -version 2.0
# No help (yet) because I'm still changing and renaming everything every time I mess with this code
Add-Type -Assembly System.ServiceModel.Web, System.Runtime.Serialization
$utf8 = [System.Text.Encoding]::UTF8
function Convert-JsonToXml
{
PARAM([Parameter(ValueFromPipeline=$true)][strin... |
PowerShellCorpus/PoshCode/8bcc60bd-75ac-494b-9b5a-36860a627c35.ps1 | 8bcc60bd-75ac-494b-9b5a-36860a627c35.ps1 | #Generated Form Function
function GenerateForm {
########################################################################
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK
# OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#
# Code Generated By: Richard ... |
PowerShellCorpus/PoshCode/Get Network Utilization_2.ps1 | Get Network Utilization_2.ps1 | $counters = @()
foreach ($inst in (new-object System.Diagnostics.PerformanceCounterCategory("network interface")).GetInstanceNames()){
$cur = New-Object system.Diagnostics.PerformanceCounter('Network Interface','Bytes Total/sec', $inst)
$max = New-Object system.Diagnostics.PerformanceCounter('Network Interface',... |
PowerShellCorpus/PoshCode/Script permissions_2.ps1 | Script permissions_2.ps1 | <#
.SYNOPSIS
Applies permissions and roles to vSphere vApps
.DESCRIPTION
Applies permissions and roles to vSphere vApps
-VIServer (Optional, defaults to Development) {FQDN of VCentre Server}
-AppName (Required) {VApp Label}
-ADGroup (Optional) {Domain\\Group_Object}
-Role (Optional) {vSphere Role, ReadO... |
PowerShellCorpus/PoshCode/Add-ExtendedFileProperti.ps1 | Add-ExtendedFileProperti.ps1 | ##############################################################################\n##\n## Add-ExtendedFileProperties\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\... |
PowerShellCorpus/PoshCode/Test-IPMask.ps1 | Test-IPMask.ps1 | <#
.SYNOPSIS
Tests for a valid IP mask.
.DESCRIPTION
The Test-IPMask script validates the input string against all CIDR subnet masks and returns a boolean value.
.PARAMETER IPMask
The IP mask to be evaluated.
.EXAMPLE
Test-IPMask 255.255.255.0
Description
-----------
Tests if the I... |
PowerShellCorpus/PoshCode/SharePoint Large Lists_2.ps1 | SharePoint Large Lists_2.ps1 | [reflection.assembly]::loadwithpartialname("Microsoft.SharePoint")
$cs = [microsoft.sharepoint.administration.spwebservice]::ContentService
$global:largeListThreshhold = 2000
function Is-Admin([Microsoft.SharePoint.SPRoleAssignment]$roleAssignment)
{
return (($roleAssignment.roledefinitionbindings | where { ($_... |
PowerShellCorpus/PoshCode/WPFDbSpace.ps1 | WPFDbSpace.ps1 | #Usage: Get-SqlDatabase 'Z002\\Sql2k8' | where {$_.name -like "pubs*"} | ./WPFDbSpace.ps1
#Note: Requires .NET 3.5, Visifire Charts (tested on v2.1.0), Powerboots (tested on v0.1), and SQLPSX (tested on v1.5)
$libraryDir = Convert-Path (Resolve-Path "$ProfileDir\\Libraries")
[Void][Reflection.Assembly]::LoadFrom( ... |
PowerShellCorpus/PoshCode/Get-Help.ps1 | Get-Help.ps1 | #function get-help() {\ncmdlet -DefaultParameterSet AllUsersView `\n\nparam(\n [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]\n [System.String]\n $Name,\n\n [ValidateSet("Alias","Cmdlet","Provider","General","FAQ","Glossary","HelpFile","All")]\n [System.String[]]\n $Category,\n\n [System.S... |
PowerShellCorpus/PoshCode/DNS functions_1.ps1 | DNS functions_1.ps1 | Param (
[Parameter(Mandatory=$true, Position=1)][string] $SourceServer,
[Parameter(Mandatory=$true, Position=2)][string] $SourceZone,
[Parameter(Mandatory=$true, Position=3)][string] $DestinationServer,
[Parameter(Mandatory=$true, Position=4)][string] $DestinationZone,
[string[]] $RRtypes = @("MicrosoftDNS_AType")... |
PowerShellCorpus/PoshCode/Select-CLSCompliant.ps1 | Select-CLSCompliant.ps1 |
function Select-CLSCompliant {
#.Synopsis
# Outputs the same as "Select-Object *" with basic error handling for properties that are not CLS Compliant
[CmdletBinding()]
param([Parameter(ValueFromPipeline=$true)]$InputObject)
process {
foreach($in in $InputObject) {
$In | Select-Object *
tra... |
PowerShellCorpus/PoshCode/The Old Dogs ExcelCookBo_1.ps1 | The Old Dogs ExcelCookBo_1.ps1 | #
# DATE : 6/21/2010
# COMMENT: This is an updated Version of my Cook Book from Augest of 2008
#
#
#===============================================================
# All errors and mistakes are my own. Thanks to all who have helped
# along the way.
#
# One thing I would add is that if you are using anything... |
PowerShellCorpus/PoshCode/NTFS ACLs Folder Tree_1.ps1 | NTFS ACLs Folder Tree_1.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/mstsc-Ac.ps1 | mstsc-Ac.ps1 | <#
.SYNOPSIS
mstsc-Ac.ps1 (Version 1.0, 7 Jan 2012)
The author may be contacted via zippy1981@gmail.com
The latest authoritative version of this script is always available at
http://bit.ly/mstsc-Ac
.DESCRIPTION
This script will see if a host is up and listening on a given port, and start a
remote desktop conn... |
PowerShellCorpus/PoshCode/powershell ise config_1.ps1 | powershell ise config_1.ps1 | <configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0" />
<process>
<rollForward enabled="false" />
</process>
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
|
PowerShellCorpus/PoshCode/Write-ASCII-Letters.ps1 | Write-ASCII-Letters.ps1 | #
#.SYNOPSIS
# Svendsen Tech's PowerShell ASCII art script creates ASCII art characters
# from a subset of common letters, numbers and punctuation characters.
# You can add new characters by editing the XML and updating the
# $AcceptedChars regexp.
#
# Author: Joakim Svendsen, Svendsen Tech
#
#.DESCRIPTION
# ... |
PowerShellCorpus/PoshCode/CSV Validator Framework_1.ps1 | CSV Validator Framework_1.ps1 | # --- begin test-csv.ps1 ---
param(
[string]$Path = $(throw "require CSV path!"),
[string]$RulesetPath = $(throw "require Ruleset path!")
)
$csvFiles = Resolve-Path -Path $Path
# load rules
if ((Test-Path (Resolve-Path $RulesetPath))) {
# ruleset is found, execute and assign result to vari... |
PowerShellCorpus/PoshCode/Fridays thirteenth.ps1 | Fridays thirteenth.ps1 | function Get-FridaysThirteenth {
param (
[datetime]$end = "12/31/2010"
)
[DateTime]$begin = "02/13/2009"
for ($i = $begin; $i -lt $end; $i = $i.AddMonths(1)) {
if ($i.DayOfWeek -eq 'Friday') {
"{0:d}" -f $i
} #if
} #for
} #function
|
PowerShellCorpus/PoshCode/Findup_24.ps1 | Findup_24.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;
using System.Text.RegularExpressions;
namespace Findup
{
public class FileLengthComparer : I... |
PowerShellCorpus/PoshCode/Create SP2010 Farm V_4.ps1 | Create SP2010 Farm V_4.ps1 | ############################################################################
## Create-SPFarm
## V 0.3
## Jos.Verlinde
############################################################################
Param ( [String] $Farm = "SP2010",
[String] $SQLServer = $env:COMPUTERNAME,
[String] $Passphrase = "pass@word1"... |
PowerShellCorpus/PoshCode/WSUS Admin Module.ps1 | WSUS Admin Module.ps1 | Write-Host "`n"
Write-Host "`t`tWSUS Administrator Module 1.0"
Write-Host "`n"
Write-Host -nonewline "Make initial connection to WSUS Server:`t"
Write-Host -fore Yellow "Connect-WSUSServer"
Write-Host -nonewline "Disconnect from WSUS Server:`t`t"
Write-Host -fore Yellow "Disconnect-WSUSServer"
Write-Host -nonewl... |
PowerShellCorpus/PoshCode/Empty working set.ps1 | Empty working set.ps1 | # use it as follows:
# PS C:\\> ps explorer | trim
add-type -Namespace Win32 -Name Psapi -MemberDefinition @"
[DllImport("psapi", SetLastError=true)]
public static extern bool EmptyWorkingSet(IntPtr hProcess);
"@
filter Reset-WorkingSet {
[Win32.Psapi]::EmptyWorkingSet($_.Handle)
}
sal trim Res... |
PowerShellCorpus/PoshCode/Coloring text in RichTex.ps1 | Coloring text in RichTex.ps1 | #code showing in RichTextBox
$code = @'
using System;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
[assembly: AssemblyVersion("3.5.0.0")]
namespace ProcessesSortedWithStartTime {
internal sealed class Program {
static DateTime Started(Process p) {
try {
return... |
PowerShellCorpus/PoshCode/2c605667-d02a-4251-bacb-0dae618c9f87.ps1 | 2c605667-d02a-4251-bacb-0dae618c9f87.ps1 | function Update-Scopes($siteUrl)
{
[void][reflection.assembly]::Loadwithpartialname("Microsoft.SharePoint") | out-null
[void][reflection.assembly]::Loadwithpartialname("Microsoft.office.server.search") | out-null
$s = [microsoft.sharepoint.spsite]$siteUrl
$sc = [microsoft.office.server.servercontext]::GetCo... |
PowerShellCorpus/PoshCode/format-custom_1.ps1 | format-custom_1.ps1 | ## UI Automation v 1.8 -- REQUIRES the Reflection module (current version: http://poshcode.org/3174 )
##
# 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/Get-ChildItemRecurse_2.ps1 | Get-ChildItemRecurse_2.ps1 | function Get-ChildItemRecurse {
<#
.Synopsis
Does a recursive search through a PSDrive up to n levels.
.Description
Does a recursive directory search, allowing the user to specify the number of
levels to search.
.Parameter path
The starting path.
.Parameter fileglob
(optional) the search string for ... |
PowerShellCorpus/PoshCode/Draw with PowerShell.ps1 | Draw with PowerShell.ps1 | Add-Type -Assembly PresentationFramework
[xml]$xaml = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="423"
Height="370"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Title="Butt... |
PowerShellCorpus/PoshCode/ConvertTo-PseudoType_1.ps1 | ConvertTo-PseudoType_1.ps1 | function ConvertTo-PseudoType {
<#
.Synopsis
Converts objects to custom PSObjects with robust type support
.Parameter TypeName
The name(s) of the PseudoType(s) to be inserted into the objects for the sake of formatting
.Parameter Mapping
A Hashtable of property names to types (or conversion scripts)
.P... |
PowerShellCorpus/PoshCode/Out-Working.ps1 | Out-Working.ps1 | ## You'll want to dot-source this into your script
## To change colors, specify the parameters:
## . Scripts\\OutWorkingScript.ps1 "Yellow" "Blue"
##
## Then you can show progress like this:
##
## $x = 1..50 | out-working 50
##
## Notice that the $wait parameter is only needed if there will not
## be enough... |
PowerShellCorpus/PoshCode/Set-IPAddress_1.ps1 | Set-IPAddress_1.ps1 | function Set-IPAddress {
param( [string]$networkinterface =$(read-host "Enter the name of the NIC (ie Local Area Connection)"),
[string]$ip = $(read-host "Enter an IP Address (ie 10.10.10.10)"),
[string]$mask = $(read-host "Enter the subnet mask (ie 255.255.255.0)"),
[string]$gateway = $(read-host "E... |
PowerShellCorpus/PoshCode/ScheduleGPOBackups_1.ps1 | ScheduleGPOBackups_1.ps1 | Import-Module grouppolicy
#region ConfigBlock
# What domain are we going to backup GPOs for?
$domain = "mydomain.com"
# Where are we going to store the backups?
$gpoBackupRootDir = "c:\\gpoBackups"
# As I plan to do a new backup set each month I'll setup the directory names to reflect
# the year and month in a n... |
PowerShellCorpus/PoshCode/Quest Dynamic Group 002.ps1 | Quest Dynamic Group 002.ps1 | <#
2012.07.06
Information will be uploaded shortly.
#>
|
PowerShellCorpus/PoshCode/ConvertTo-Hex_5.ps1 | ConvertTo-Hex_5.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[] ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.