full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Search-Network.ps1 | Search-Network.ps1 | #Define PreReqs
$timeStamp = Get-Date -UFormat "%m-%d-%Y-%H-%M"
$systemVars = Gwmi Win32_ComputerSystem -Comp "."
$userName = $systemVars.UserName
$compName = $systemVars.Name
#User Vars
$serviceName = "Spooler" # Spooler will check the Print Spooler <<< Change To Suit Your needs
$errorLog = "C:\\Temp\\Log_"+$... |
PowerShellCorpus/PoshCode/Get-Link.ps1 | Get-Link.ps1 | param([Parameter(ValueFromPipelineByPropertyName=$true)][Alias("PSPath")][string]$Path)
begin {
Add-Type -TypeDef @"
using System;
using System.IO;
using System.Text;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Huddled.Interop
{
... |
PowerShellCorpus/PoshCode/Migrate UserFolder_2.ps1 | Migrate UserFolder_2.ps1 | param(
$RootFolder = "\\\\server1\\users",
$NewRootFolder = "\\\\server2\\users",
$LogFolder = "C:\\Projects\\HomeDirs",
$NewSubFolders = @("Documents","Favorites","Desktop","Links","Contacts"),
$domain = "domain",
[switch]$SetACL
)
$UserFolders = gci -Path $RootFolder | ?{$_.PSIsContainer}
$UserFolders | fore... |
PowerShellCorpus/PoshCode/Copy-FilePlus.ps1 | Copy-FilePlus.ps1 | <#
.SYNOPSIS
Copies a file from one location to another while displaying a GUI progress window.
.PARAMETER Path
Specifies the filename or FileInfo object representing file to be copied. Right now, this must be fully-qualified, relative paths will produce an error. Try it with Get-Item or Get-ChildItem, this wor... |
PowerShellCorpus/PoshCode/Set-IPAddress_5.ps1 | Set-IPAddress_5.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/ShowUI Text Converter_1.ps1 | ShowUI Text Converter_1.ps1 | #Import-Module showui
$Windowparam = @{
Width = 500
Height = 400
Title = 'Fun Text Converter'
Background = '#C4CBD8'
WindowStartupLocation = 'CenterScreen'
AsJob = $True
}
#Create Window
New-Window @Windowparam {
New-Grid -Rows *,Auto,*,Auto -Children {
New-TextBox -Row... |
PowerShellCorpus/PoshCode/Set-AppCompatFlag.ps1 | Set-AppCompatFlag.ps1 | <#
.SYNOPSIS
Sets the Compatibility flags for an application.
.EXAMPLE
Set-AppCompatFlag.ps1 -Path 'c:\\windows\\system32\\WindowsPowerShell\\v1.0\\PowerShell_ISE.exe'
This sets the RUNASADMIN flag for the ISE
.EXAMPLE
Set-AppCompatFlag... |
PowerShellCorpus/PoshCode/Get-FactualData.ps1 | Get-FactualData.ps1 | # Get data from factual.com. Currently you need an API key to even query data so you'll
# have to set one up before you can use this. Set your API key to the global variable
# APIKEY. Hopefully one day factual will allow reads without requiring API keys, which
# is why I chose not to make it an argument to the funct... |
PowerShellCorpus/PoshCode/Compare-SQLResultSet.ps1 | Compare-SQLResultSet.ps1 | <#
.SYNOPSIS
Compares two result sets from SQL queries for differences.
.DESCRIPTION
Compares the result sets from two SQL queries and outputs the
differences.
Currently the function only handles similarly shaped result sets. That is,
result sets with the same number and names of columns. Functiona... |
PowerShellCorpus/PoshCode/Findup_2.ps1 | Findup_2.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/Convert-BounceToX_7.ps1 | Convert-BounceToX_7.ps1 | # $Id: Convert-BounceToX500.ps1 610 2010-11-16 00:39:19Z jon $
# $Revision: 610 $
#.Synopsis
# Convert Bounce to X500
#.Description
# Convert URL Encoded address in a Bounce message to an X500 address
# that can be added as an alias to the mail-enabled object
#.Parameter bounceAddress
# URL Encoded bounce... |
PowerShellCorpus/PoshCode/Invoke-Inline.ps1 | Invoke-Inline.ps1 | ################################################################################
## Invoke-Inline.ps1 (originally from Lee Holmes)
## Library support for inline C#
##
## Modified by Joel Bennett to accept include statements, and return collections
##
## Usage
## 1) Define just the body of a C# method, and s... |
PowerShellCorpus/PoshCode/Manage ASP_3.NET Providers.ps1 | Manage ASP_3.NET Providers.ps1 | # Manage_ASP_NET_Providers.ps1
# by Chistian Glessner
# http://iLoveSharePoint.com
# have to be initialized. If you want to change the app config you have to restart PowerShell
param($appConfigPath=$(throw "-appConfigPath is mandatory"))
# App config path have to be set before loading System.Web.dll
[System.A... |
PowerShellCorpus/PoshCode/My Profile.ps1 | My Profile.ps1 | ## If your PC doesn't have this set already, someone could tamper with this script...
## but at least now, they can't tamper with any of the scripts that I auto-load!
Set-ExecutionPolicy AllSigned Process
## Set the profile directory first, so we can refer to it from now on.
Set-Variable ProfileDir (Split-Path $MyI... |
PowerShellCorpus/PoshCode/Get-VMHostNetworks.ps1 | Get-VMHostNetworks.ps1 | Function Get-VMHostNetworks
{
<#
.SYNOPSIS
Return a list of networks from a given host
.DESCRIPTION
After connecting to your VI server, we get a list of virtual switches on the datacenter and from
that we pull out the VHostID that matches the server we pass... |
PowerShellCorpus/PoshCode/Autoload (beta 4).ps1 | Autoload (beta 4).ps1 | #Requires -Version 2.0
## Version History
## beta 4 - 2010.05.10
## I made a few tweaks and bug fixes while testing it's use with PowerBoots.
## beta 3 - 2010.05.10
## fix for signed scripts (strip signature)
## beta 2 - 2010.05.09
## implement module support
## beta 1 - 2010.04.14
... |
PowerShellCorpus/PoshCode/A Process Block.ps1 | A Process Block.ps1 | Process {
#Get the type of object we have
$InputTypeName = $_.GetType().Name
#Do something with that object
#is it VMware?
if ( $InputTypeName -eq "VMHostImpl" ) {
$output = $_ | Get-View | Select-Object $VMHost_UUID
#is it Xen?
} elseif ($InputTypeName -eq "Host"){
$output = $_ | g... |
PowerShellCorpus/PoshCode/EchoTest.cmd.ps1 | EchoTest.cmd.ps1 | @Echo 00: %0
@Echo 01: %1
@Echo 02: %2
@Echo 03: %3
@Echo 04: %4
@Echo 05: %5
@Echo 06: %6
@Echo 07: %7
@Echo 08: %8
@Echo 09: %9
@Echo All together, it looked like this to DOS:
@Echo %0 %*
|
PowerShellCorpus/PoshCode/Get-WebSite_3.ps1 | Get-WebSite_3.ps1 | function Get-WebPage {
<#
.SYNOPSIS
Downloads web page from site.
.DESCRIPTION
Downloads web page from site and displays source code or displays total bytes of webpage downloaded
.PARAMETER Url
URL of the website to test access to.
.PARAMETER UseDefaultCredentials
Use the currently authentica... |
PowerShellCorpus/PoshCode/Get-WMIVersions_3.ps1 | Get-WMIVersions_3.ps1 | #Requires -Version 2
param ( $Credential, $ComputerName )
# The official way to detect .NET versions is to look at their known location on the hard drive as per
# this article: http://msdn.microsoft.com/en-us/kb/kb00318785.aspx
# thanks to David M (http://twitter.com/makovec) for the WQL
$query = "select name... |
PowerShellCorpus/PoshCode/New-XVM_4.ps1 | New-XVM_4.ps1 | #Examples
<#
New-XVM -Name "WS2012-TestServer01" -SwitchName "Switch(192.168.2.0/24)" -VhdType NoVHD
New-XVM -Name "WS2012-TestServer02" -SwitchName "Switch(192.168.2.0/24)" -VhdType ExistingVHD -VhdPath 'D:\\vhds\\WS2012-TestServer02.vhdx'
New-XVM -Name "WS2012-TestServer03" -SwitchName "Switch(192.168.2.0/24)" ... |
PowerShellCorpus/PoshCode/out-form with sort colum.ps1 | out-form with sort colum.ps1 | I think OUT-FORM is a very usefull function. I've added code to sort columns by clicking on headers.
You nedd just add the columnTag parameters specifing if colunm value is text or numeric:
out-form -data (get-process) -columnNames ("Name", "ID" ) -columnProperties ("Name", "ID") -columnTag ("Text", "Numeric")
... |
PowerShellCorpus/PoshCode/Read-HostMasked_1.ps1 | Read-HostMasked_1.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/The PowerShell Talk 2.ps1 | The PowerShell Talk 2.ps1 | #The PowerShell Talk
#Demo 2 - VM Easy Bake Oven
#VMware
#Connect to vCenter
Get-Credential | connect-viserver -Server "Your vCenter Here"
#Create the new VM
get-vmhost -Name "ESX Server" | New-VM -Name Dave -DiskMB "10240" -GuestId "otherGuest" -MemoryMB 512 -NumCpu 1 -resourcepool "Demo"
#Get some info ... |
PowerShellCorpus/PoshCode/ac3d3fd4-f5da-4eeb-8a26-50cf89f15d26.ps1 | ac3d3fd4-f5da-4eeb-8a26-50cf89f15d26.ps1 | <#
.SYNOPSIS
Pulls down the leaderboards for the 2011 Scripting Games
.DESCRIPTION
Quick and dirty script to pull down the leaderboards for the 2011 scripting games.
Can choose either beginner or advanced via a command line switch.
.PARAMETER Level
The leaderboard to parse
.EXAMPLE
Get... |
PowerShellCorpus/PoshCode/Find Local Group Members_1.ps1 | Find Local Group Members_1.ps1 | # Author: Hal Rottenberg
# Purpose: Find matching members in a local group
# Used tip from RichS here: http://powershellcommunity.org/Forums/tabid/54/view/topic/postid/1528/Default.aspx
# Change these two to suit your needs
$ChildGroups = "Domain Admins", "Group Two"
$LocalGroup = "Administrators"
$MemberName... |
PowerShellCorpus/PoshCode/Findup_30.ps1 | Findup_30.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/Format-Column.ps1 | Format-Column.ps1 | function global:Format-Column {
################################################################
#.Synopsis
# Formats incoming data to columns.
#.Description
# It works similarly as Format-Wide but it works vertically. Format-Wide outputs
# the data row by row, but Format-Columns outputs them column by column.... |
PowerShellCorpus/PoshCode/Get-HostsFile_2.ps1 | Get-HostsFile_2.ps1 | Function Get-HostsFile {
<#
.SYNOPSIS
Retrieves the contents of a hosts file on a specified system.
.DESCRIPTION
Retrieves the contents of a hosts file on a specified system.
.PARAMETER ComputerName
The computers to access.
.NOTES
Name: Get-HostsFile
Author: Boe Prox
DateCreated: 15Ma... |
PowerShellCorpus/PoshCode/Set-Opacity.ps1 | Set-Opacity.ps1 | #.Synopsis\n # Mess with the transparency and blur of the PowerShell window\n #.Parameter color\n # The color to treat as transparent (you can set this to your foreground or background for best effect, but you must pass an actual [Drawing.Color]\n #.Parameter opacity\n # On a scale of 0 to 255, how opaque ... |
PowerShellCorpus/PoshCode/Get-WebFile _2.7.3.ps1 | Get-WebFile _2.7.3.ps1 | function Get-WebFile {
<#
.SYNOPSIS
Downloads a file or page from the web.
.DESCRIPTION
Downloads a file or page from the web (aka wget for PowerShell).
.PARAMETER URL
The URL to download.
.PARAMETER FileName
Download file path.
If ommitted, the name is autmaitcally determined and
down... |
PowerShellCorpus/PoshCode/Search-WmiNamespace.ps1 | Search-WmiNamespace.ps1 | ##############################################################################\n##\n## Search-WmiNamespace\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\nSear... |
PowerShellCorpus/PoshCode/Select-ViaGUI.ps1 | Select-ViaGUI.ps1 | ## Select-ViaGui.ps1
## Use a graphical interface to select (and pass-through) pipeline objects
## originally by Lee Holmes (http://www.leeholmes.com/blog), although he might not recognize it now ;-)
Import-Module ShowUI
## Get the item as it would be displayed by Format-Table
## Generate the window
Show-UI -Ti... |
PowerShellCorpus/PoshCode/New-StoredProcFunction_2.ps1 | New-StoredProcFunction_2.ps1 | # New-StoredProcFunction.ps1
# Steven Murawski
# http://blog.usepowershell.com
# 04/08/2009
# Example: ./New-StoredProcFunction.ps1 'Data Source=MySqlServer;Database=Northwind;User=AnythingButSa;Password=abc123' sp_createnewcustomer
# Example 'sp_createnewcustomer | ./New-StoredProcFunction.ps1 'Data Source=MySq... |
PowerShellCorpus/PoshCode/Reflection Module_1.ps1 | Reflection Module_1.ps1 | #requires -version 2.0
# ALSO REQUIRES Autoload for some functionality
# You should create a Reflection.psd1 with the contents: @{ RequiredModules = @("Autoload"); GUID="64b5f609-970f-4e65-b02f-93ccf3e60cbb"; ModuleVersion="3.5.0.0" }
#History:
# 1.0 - First public release (March 19, 2010)
# 2.0 - Private Build
... |
PowerShellCorpus/PoshCode/out-form with sort colum_1.ps1 | out-form with sort colum_1.ps1 | I think OUT-FORM is a very usefull function. I've added code to sort columns by clicking on headers.
You nedd just add the columnTag parameters specifing if colunm value is text or numeric:
out-form -data (get-process) -columnNames ("Name", "ID" ) -columnProperties ("Name", "ID") -columnTag ("Text", "Numeric")
... |
PowerShellCorpus/PoshCode/Set-WLWAutoLink.ps1 | Set-WLWAutoLink.ps1 | #requires -version 2
function Set-WLWAutoLink{
param(
[Parameter(
Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true
)] [String]$Name,
[Parameter(
Position=1,Mandatory=$true,ValueFromPipelineByPropertyName=$true
)] ... |
PowerShellCorpus/PoshCode/Get-ActivesyncUsers.ps1 | Get-ActivesyncUsers.ps1 | #Get all mailboxes that have an active sync partnership:
$Mailboxes = Get-CASMailbox -Filter{HasActiveSyncDevicePartnership -eq $true}| select name, servername, DistinguisheDName, ActiveSyncMailboxPolicy
$NumberWiped = 0
$NumberSent =0
$TotalCount = 0
Foreach ($mailbox in $Mailboxes)
{
$Name = $mailbox.Name
$... |
PowerShellCorpus/PoshCode/Get-UnityLicense.ps1 | Get-UnityLicense.ps1 | #
# get-unitylicense.ps1
#
# Returns license information for a Cisco Unity environment
# Usage: get-unitylicense <server>
#
# Author: Robbie Foust (rfoust@duke.edu)
#
function global:get-unitylicense ([string]$server = $(throw "Please provide a server name!"))
{
$webContent = new-object net.webclient
... |
PowerShellCorpus/PoshCode/Backup-ModifiedGPOs.ps1 | Backup-ModifiedGPOs.ps1 | ###########################################################################"
#
# NAME: Backup-ModifiedGPOs.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jan.egil.ring@powershell.no
#
# COMMENT: All Group Policy Objects modified in the specified timespan are backup up to the specified backup path.
# For more d... |
PowerShellCorpus/PoshCode/Get-Hostname_4.ps1 | Get-Hostname_4.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/Invoke-Generic_3.ps1 | Invoke-Generic_3.ps1 | function Invoke-Generic {
#.Synopsis
# Invoke Generic method definitions via reflection:
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)]
[Alias('On')]
$InputObject
,
[Parameter(Position=1,ValueFromPipelineByPropertyName=$true)]
[Alias('Na... |
PowerShellCorpus/PoshCode/Monitor-FileSize.ps1 | Monitor-FileSize.ps1 | function Monitor-FileSize
{
<#
.Synopsis
Checks the file size of a given file until it reaches the specified size
.Description
Checks the file size of a given file until it reaches the specified size. AT that point, it alerts the user as to what the original file-size-boundry was and what it currentl... |
PowerShellCorpus/PoshCode/Logger.psm1.ps1 | Logger.psm1.ps1 | <#
Name : Universal Log4Net Logging Module (Logger.psm1)
Version : 0.1
Author : Joel Bennett (MVP)
Site : http://www.HuddledMasses.org/
See Also : http://poshcode.org/1743
You should download this config and put it in your Modules\\Logger folder with this Logger.psm1
Uses L... |
PowerShellCorpus/PoshCode/Disconnect-VMHost_1.ps1 | Disconnect-VMHost_1.ps1 | #requires -version 2
#requires -pssnapin VMware.VimAutomation.Core
Function Disconnect-VMHost {
<#
.Summary
Used to Disconnect a Connected host from vCenter.
.Parameter VMHost
VMHost to Disconnect to virtual center
.Example
Get-VMHost | Where-Object {$_.state -eq "Conn... |
PowerShellCorpus/PoshCode/Open-ISEFile Posh v3.ps1 | Open-ISEFile Posh v3.ps1 | #Requires -Version 3.0
function Open-ISEFile {
<#
.NOTES
Name: Open-ISEFile
Author: Tome Tanasovski
Created: 6/20/2010
Version: 2.0a
History: 1.0 6/20/2010 Initial Release
2.0 4/1/2012
Updated for v3
Added support to launch in ISE even if you are not in an ... |
PowerShellCorpus/PoshCode/Test-Transcribing.ps1 | Test-Transcribing.ps1 | #requires -version 2.0
function Test-Transcribing {
$externalHost = $host.gettype().getproperty("ExternalHost",
[reflection.bindingflags]"NonPublic,Instance").getvalue($host, @())
try {
$consoleHost.gettype().getproperty("IsTranscribing",
[reflection.bindingflags]"NonPublic,Instance").getvalue($con... |
PowerShellCorpus/PoshCode/Invoke-SqlCmd_7.ps1 | Invoke-SqlCmd_7.ps1 | #######################
<#
.SYNOPSIS
Runs a T-SQL script.
.DESCRIPTION
Runs a T-SQL script. Invoke-Sqlcmd2 only returns message output, such as the output of PRINT statements when -verbose parameter is specified.
Paramaterized queries are supported.
.INPUTS
None
You cannot pipe objects to Invoke-Sq... |
PowerShellCorpus/PoshCode/ASPX Mailbox (4 of 6).ps1 | ASPX Mailbox (4 of 6).ps1 | using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Net.Mail;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Mailb... |
PowerShellCorpus/PoshCode/433da2cf-0b3d-481c-827e-375cf9760770.ps1 | 433da2cf-0b3d-481c-827e-375cf9760770.ps1 | function Get-ParameterEnum
{
<#
.Synopsis
Displays enumeration values for specific parameter.
.Description
For provided combination of cmdlet/parameter displays all possible values. Parameter has to be
enumeration type. Displays also numeric value and enumeration name.
.Parameter Cmdlet
Name of... |
PowerShellCorpus/PoshCode/4ddb6e30-dac0-481f-b6b5-547139c8a98a.ps1 | 4ddb6e30-dac0-481f-b6b5-547139c8a98a.ps1 | Coresponding to the Scripting Guy blog "How Can I Both Save Information in a File and Display It on the Screen?"
(http://blogs.technet.com/heyscriptingguy/archive/2009/07/07/hey-scripting-guy-how-can-i-both-save-information-in-a-file-and-display-it-on-the-screen.aspx):
My comment is:
All of the above is cool but can... |
PowerShellCorpus/PoshCode/SSL Oblivious Web Client_1.ps1 | SSL Oblivious Web Client_1.ps1 | function New-TrustAllWebClient {
# Create a compilation environment
$Provider=New-Object Microsoft.CSharp.CSharpCodeProvider
$Compiler=$Provider.CreateCompiler()
$Params=New-Object System.CodeDom.Compiler.CompilerParameters
$Params.GenerateExecutable=$False
$Params.GenerateInMemory=$True
$Params.IncludeDe... |
PowerShellCorpus/PoshCode/8eb8f683-4672-43f6-ae5a-77f76eb77c88.ps1 | 8eb8f683-4672-43f6-ae5a-77f76eb77c88.ps1 | #You Need Quest AD Powershell Plugin
#You Need VMWare VI Toolkit
$Null = Connect-VIServer Your-VM-Server-Here;
$Servers = New-Object System.Collections.ArrayList
$Null = Get-QADComputer -SearchRoot 'your.domain.com/Path/To/Server/OU' | Select-Object -property Name | Format-Table -HideTableHeaders| Out-String... |
PowerShellCorpus/PoshCode/LNK file testing.ps1 | LNK file testing.ps1 | param(
$Path = (Split-Path $PSHOME -Qualifier)
)
if($lnks -eq $null) {
$lnks = ls -Recurse $Path | ?{$_.extension.tolower() -eq ".lnk"}
}
$wsh = New-Object -ComObject WScript.Shell;
foreach($lnk in $lnks) {
$lnko = $wsh.CreateShortcut($lnk.fullname);
$rtn = New-Object psobject -Property... |
PowerShellCorpus/PoshCode/Add-SharePointLibraryFil.ps1 | Add-SharePointLibraryFil.ps1 | Add-SharePointLibraryFile
{
param
(
[System.IO.FileInfo] $File,
[System.Uri] $DocumentLibraryUrl = $(throw "Parameter -DocumentLibraryUrl [System.Uri] is required.")
)
Begin
{ }
Process
{
if($_)
{
$File = [System.IO.FileInfo] $_
}
if (!$File.Exists)
{
Write-Error ($... |
PowerShellCorpus/PoshCode/Get-ServiceAccounts.ps1 | Get-ServiceAccounts.ps1 | #requires -pssnapin PSCX
#Author: Glenn Sizemore gesize@get-admin.com
#Purpose: Scan a remote system for any services running under a non standard account.
# Standard accounts would be considered, NT AUTHORITY\\NetworkService,
# NT AUTHORITY\\LocalService, LocalSystem, or .\\ASPNET
# ... |
PowerShellCorpus/PoshCode/PowerCLI error report_1.ps1 | PowerCLI error report_1.ps1 | $getVmScript = {
Connect-VIServer yourVCenterServer
Get-VM
}
$ getVmScript | Get-ErrorReport -ProblemScriptTimeoutSeconds 60 -ProblemDescription "Get-VM hangs when trying to retrieve all the VMs form the server. The server’s inventory can be successfully browsed via the vClient." -Destination 'D:\\bug report'
... |
PowerShellCorpus/PoshCode/CreateVDS.ps1 | CreateVDS.ps1 | function CreateVDS(
$dvsName, $datacenter, $vmHost, $physicalNic, $portGroupType = "earlyBinding", `
[array]$portGroupNameList = @(),[array]$uplinkList = @() ) {
# ------- Create vDS ------- #
$dvsCreateSpec = New-Object VMware.Vim.DVSCreateSpec
$dvsCreateSpec.configSpec = New-Object VMware.V... |
PowerShellCorpus/PoshCode/ConvertTo-Module.ps1 | ConvertTo-Module.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/UIAutomation 1.3.ps1 | UIAutomation 1.3.ps1 | # #
# Select-Window Notepad | Remove-Window -passthru #
# ## And later ... #
# Select-Wi... |
PowerShellCorpus/PoshCode/PS file locking.ps1 | PS file locking.ps1 | #################################################
#Scriptname: checklock.ps1
#Author: Michael Rüefli (www.miru.ch)
#Date: 21.11.2009
#Description: The code uses a file locking mechanism to ensure that the
# script beeing started is running exclusively. Mostly used where
# ... |
PowerShellCorpus/PoshCode/New-RDCManFile.ps1 | New-RDCManFile.ps1 | ###########################################################################
#
# NAME: New-RDCManFile.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jer@powershell.no
#
# COMMENT: Script to create a XML-file for use with Microsoft Remote Desktop Connection Manager
# For more details, see the following blog-post... |
PowerShellCorpus/PoshCode/Deploy VM with Static IP_2.ps1 | Deploy VM with Static IP_2.ps1 | # 1. Create a simple customizations spec:
$custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows `
-OrgName “My Organization” -FullName “MyVM” -Domain “MyDomain” `
–DomainAdminUsername “user” –DomainAdminPassword “password”
# 2. Modify the default network customization settings:
$custSpe... |
PowerShellCorpus/PoshCode/Get-PasswordExpiredUser.ps1 | Get-PasswordExpiredUser.ps1 | $filter = "(&(objectCategory=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))"
$ds = new-object directoryservices.directorysearcher([adsi]"",$filter)
$users = $ds.findall()
$users | format-table @{l="User";e={$_.properties.item('cn')}},
@{l="sAMAccountName";e={$_.properties.item('sAMAc... |
PowerShellCorpus/PoshCode/Test-BufferBox 2.0.ps1 | Test-BufferBox 2.0.ps1 | ## Test-BufferBox 2.0
####################################################################################################
## 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, ... |
PowerShellCorpus/PoshCode/Multiple strings params.ps1 | Multiple strings params.ps1 | # For example I have this function
function copySourceDestination {
Param (
[string]$sourceFile,
[string]$destinationPath
)
# Strangely enough $sourceFile will contain both the values of $sourceFile and $destinationPath
# in this case $destinationPath will be empty and $sourceFile will show up as: "C:... |
PowerShellCorpus/PoshCode/Script-Proc.sql.ps1 | Script-Proc.sql.ps1 | param(
[string] $ProcedureName,
[string] $Path = "$($ProcedureName).sql",
[string] $ConnectionString = 'Data Source=.\\sqlexpress;Initial Catalog=master;Integrated Security=SSPI;'
);
try {
[System.Data.SqlClient.SqlConnection] $cn = New-Object System.Data.SqlClient.SqlConnection (,$ConnectionStr... |
PowerShellCorpus/PoshCode/ImaginaryFriendFeed.ps1 | ImaginaryFriendFeed.ps1 | function New-ImaginaryFriend {
##.Note
## DEPENDS on the WatiN module in http`://poshcode.org/1108
##.Synopsis
## Creates a new "Imaginary Friend" on friendfeed by automating your browser
##.Example
## New-ImaginaryFriend PoshCode @{Twitter="PoshCode"} http`://poshcode.org/PoshCode.png
##
[CmdletBindin... |
PowerShellCorpus/PoshCode/Get-WebFile _2.6.ps1 | Get-WebFile _2.6.ps1 | ## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.7 - Added Credentials parameter for passing credentials via System.Net.NetworkCredential
## v3.6 - Add -... |
PowerShellCorpus/PoshCode/Logging AD logins.ps1 | Logging AD logins.ps1 | #* FileName: loginTime.ps1
#*=============================================================================
#* Created: [09/25/2009]
#* Author: Alan Oakland
#*=============================================================================
#* Purpose: Create a log of login times.
#*===================================... |
PowerShellCorpus/PoshCode/finddupe_4.ps1 | finddupe_4.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/remove-ADobject.ps1 | remove-ADobject.ps1 | ######################################################
# Script to remove unauthorized objects from AD group
# (c) Josh Coen
# Requires AD cmdlets
######################################################
# set path and file name in $strFile
# file should contain authorized usernames or groups one on each line
# ... |
PowerShellCorpus/PoshCode/Start-Presentation_2.ps1 | Start-Presentation_2.ps1 | if(-not(get-command New-System.Windows.Window -EA 0)){ Import-Module PowerBoots }
Add-BootsTemplate $PSScriptRoot\\PresentationFrame.xaml
$name = [System.Windows.Navigation.JournalEntry]::NameProperty
[double]$global:zoomLevel = 1
$SlideCount = 0
function Start-Zoom {
PARAM(
[Parameter(Position=0)]
... |
PowerShellCorpus/PoshCode/Newer-LinkedClone.ps1 | Newer-LinkedClone.ps1 | #Requires -version 2
# TITLE: Newer-LinkedClone.ps1
# AUTHOR: Cameron Smith (original by Hal Rottenberg)
# Adapted from a technique published originally by Keshav Attrey http://www.vmdev.info/?p=40
# Also see William Lam's Perl script: http://engineering.ucsb.edu/~duonglt/vmware/vGhettoLinkedClone.html
# And Le... |
PowerShellCorpus/PoshCode/The PowerShell Talk Demo.ps1 | The PowerShell Talk Demo.ps1 | #The PowerShell Takl
#Demo 1 - Hypervisors
#ESX
#Connect to vCenter
Get-Credential | connect-viserver -Server "Your vCenter Address"
#Create Our Network
Get-VMHost "ESXServerName" | New-VirtualSwitch -Name "Test" -NumPorts 64
#And a Port Group on that network
Get-VMHost "ESXServerName" | get-virtualswitch... |
PowerShellCorpus/PoshCode/IADsDNWithBinary Cmdlet.ps1 | IADsDNWithBinary Cmdlet.ps1 | @@//Adapted from code @ http://mow001.blogspot.com/2006/01/msh-snap-in-to-translate.html Thanks!
using System;
using System.ComponentModel;
using System.Management.Automation;
using System.Reflection;
using System.Diagnostics;
namespace space
{
// This class defines the properties of a snap-in
[... |
PowerShellCorpus/PoshCode/Create-Mdb.ps1 | Create-Mdb.ps1 | # Copyright (c) 2011 Justin Dearing <zippy1981@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, m... |
PowerShellCorpus/PoshCode/get attach. from Lotus.ps1 | get attach. from Lotus.ps1 | Param (
[Parameter(ValueFromPipelineByPropertyName=$True,
HelpMessage='Lotus Domino Server')]
$ServerName,
[Parameter(ValueFromPipelineByPropertyName=$True,
HelpMessage='Lotus Mail Database')]
$Database,
[Parameter(ValueFromPipelineByPropertyName=$True,
HelpMessage='View to Select')]
$View,
[P... |
PowerShellCorpus/PoshCode/New-XVM.ps1 | New-XVM.ps1 | #Examples
<#
New-XVM -Name "WS2012-TestServer01" -SwitchName "Switch(192.168.2.0/24)" -VhdType NoVHD
New-XVM -Name "WS2012-TestServer02" -SwitchName "Switch(192.168.2.0/24)" -VhdType ExistingVHD -VhdPath 'D:\\vhds\\WS2012-TestServer02.vhdx'
New-XVM -Name "WS2012-TestServer03" -SwitchName "Switch(192.168.2.0/24)" ... |
PowerShellCorpus/PoshCode/Get-FreeDiskSpace.ps1 | Get-FreeDiskSpace.ps1 | <#
.SYNOPSIS
Return free space on disk
.DESCRIPTION
This script works in conjunction with an Event Trigger on the System
event on our file servers. This script queries the System log for
EventID 2013, and returns the drive letter from the most recent
event.
... |
PowerShellCorpus/PoshCode/POC csharp expressions.ps1 | POC csharp expressions.ps1 | function run-csharpexpression([string] $expression )
{
$local:name = [system.guid]::NewGuid().tostring().replace('-','_').insert(0,"csharpexpr")
$local:template = @"
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace ShellTools.DynamicCsharpExpression
{
public ... |
PowerShellCorpus/PoshCode/powertab patch_1.ps1 | powertab patch_1.ps1 | # Stick this anywhere
filter convertTypeToTabCompletionName()
{
$typeToTabCompletion=@{
[Microsoft.Powershell.Commands.X509StoreLocation]={$_.Location};
[System.Security.Cryptography.X509Certificates.X509Store]={$_.Name};
[Microsoft.Win32.RegistryKey]={ $_.Name.Split("\\"... |
PowerShellCorpus/PoshCode/h20 -Hashtables 2 object.ps1 | h20 -Hashtables 2 object.ps1 | #hashtable to object function.
#used to be able to make custom objects with math inside the pipeline
#e.g. 1..10 | h20 { @{karl = $_;dude = $_+1} }
# gps | h20 { @{name = $_.processname; mem = $_.workingset / 1MB} }
function h20([scriptblock]$sb )
{
begin {}
process{ if ($sb -ne $null)
{
... |
PowerShellCorpus/PoshCode/PresentationFrame.xaml.ps1 | PresentationFrame.xaml.ps1 | <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
<!-- Resource dictionary entries should be defined here. -->
... |
PowerShellCorpus/PoshCode/Experimental.IO 2.0.ps1 | Experimental.IO 2.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/Get-Tree.ps1 | Get-Tree.ps1 | #.Synopsis
# Creates a fir tree in your console!
#.Description
# A simple christmas tree simulation with (optional) flashing lights.
# Requires your font be set to a True Type font (best results with Consolas).
#.Parameter Trim
# Whether or not to trim the tree. NOTE: In violation of convention, this switch ... |
PowerShellCorpus/PoshCode/Get-McAfeeInfo.ps1 | Get-McAfeeInfo.ps1 | #------------------------------------------------------------------
# Produces report for McAfee AntiVirus on a set of remote computers
# Usage: get-content <list of servers.txt> | .\\GetMcAfeeInfo.ps1
# Optionally pipe output to Export-Csv, ConverTo-Html
#----------------------------------------------------... |
PowerShellCorpus/PoshCode/Get-InstalledProgram_v2.ps1 | Get-InstalledProgram_v2.ps1 | function Get-InstalledProgram() {
param (
[String[]]$Computer = "n2-ivanyuta",
$User
)
if ($User -is [String]) {
$Connection = Get-Credential -Credential $User
}
if ($Connection -eq $null){
foreach ($Comp in $Computer){
$Install_soft = gwmi win32_product -ComputerName $Comp |
where {$_.... |
PowerShellCorpus/PoshCode/New-ScriptCmdlet.ps1 | New-ScriptCmdlet.ps1 | # http://blogs.msdn.com/powershell/archive/2008/05/09/fun-with-script-cmdlets.aspx
########################################################################################
# function New-ScriptCmdlet() {
[CmdletBinding(DefaultParameterSetName="Type")]
PARAM(
[Parameter(ParameterSetName="Type",ValueFromPipeline=... |
PowerShellCorpus/PoshCode/gpupdate on remote pc's_1.ps1 | gpupdate on remote pc's_1.ps1 | ###############################################################################
#
# Get all servers from a OU and run GPUpdate /force on this machines.
#
# Version 1.0
#
# (C) 2009 - Arne Fokkema
# www.ict-freak.nl
#
# Install the Quest AD cmdlets first!!
#
###############################################... |
PowerShellCorpus/PoshCode/New-XVM_15.ps1 | New-XVM_15.ps1 | #EXAMPLES
<#
New-XVM -ComputerName CNSHHYPERVSVR02 -Name "WS2012-TESTSVR01" -SwitchName "External(192.168.1.0/24)" -VhdType NoVHD
New-XVM -ComputerName CNSHHYPERVSVR02 -Name "WS2012-TESTSVR02" -SwitchName "External(192.168.1.0/24)" -VhdType ExistingVHD -VhdPath D:\\vhds\\WS2012-TESTSVR02.vhdx
New-XVM -ComputerName ... |
PowerShellCorpus/PoshCode/Get-TopProcess_1.ps1 | Get-TopProcess_1.ps1 |
param(
[string] $sortCriteria = "Processor",
[int] $Count = 5
)
function main
{
## Store the performance counters we need
## for the CPU, and Disk I/O numbers
$cpuPerfCounters = @{}
$ioOtherOpsPerfCounters = @{}
$ioOtherBytesPerfCounters = @{}
$ioDataOpsPerfC... |
PowerShellCorpus/PoshCode/repr.ps1 | repr.ps1 | function repr {
[CmdletBinding()]
[OutputType([string])]
Param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
$InputObject)
process {
if($null -eq $InputObject) {
$PSCmdlet.WriteObject('$null')
}
elseif($InputObject -is ... |
PowerShellCorpus/PoshCode/Read-Choice_1.ps1 | Read-Choice_1.ps1 | function Read-Choice {
#.Synopsis
# Prompt the user for a choice, and return the (0-based) index of the selected item
#.Parameter Message
# The question to ask
#.Parameter Choices
# An array of strings representing the "menu" items, with optional ampersands (&) in them to mark (unique) characters to be used to... |
PowerShellCorpus/PoshCode/Get-HtmlHelp 3.2.ps1 | Get-HtmlHelp 3.2.ps1 | ## Get-HtmlHelp - by Joel Bennett
## version 3.2
#####################################################################
## Cool Example, using ShowUI:
## Import-Module HtmlHelp
## Import-Module ShowUI -Vers 1.4
## function Show-Help { [CmdletBinding()]param([String]$Name)
## Window { WebBrowser -... |
PowerShellCorpus/PoshCode/ConvertTo-Hex_2.ps1 | ConvertTo-Hex_2.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/Get-RecurseMember.ps1 | Get-RecurseMember.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-TextObject.ps1 | Convert-TextObject.ps1 | ##############################################################################\n##\n## Convert-TextObject\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\nConve... |
PowerShellCorpus/PoshCode/New-XVM_12.ps1 | New-XVM_12.ps1 | #Example
#New-XVM -ComputerName HYPERVSVR02 -Name "TLG-INET2" -SwitchName "External(192.168.1.0/24)" -VhdType Differencing -ParentVhdPath 'D:\\vhds\\Windows #Server 2012 RC Base.vhdx'
Function New-XVM
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory=$false,Position=1)]
[string]$Co... |
PowerShellCorpus/PoshCode/Invoke-Web 4.2.ps1 | Invoke-Web 4.2.ps1 | function ConvertTo-Dictionary {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName="Hashtable")]
[Hashtable[]]$Hashtable,
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName="WebHeaders")]
[System.Collections.Specialized.Na... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.