full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/GUI process explorer.ps1 | GUI process explorer.ps1 | function BuildProcessesList {
$arr = New-Object Collections.ArrayList
$script:col = ps | select Name, Id, BasePriority, Description, Company | sort Name
$arr.AddRange($col)
$dtgGrid.DataSource = $arr
$frmMain.Refresh()
}
function SelectedItemModules {
$ErrorActionPreference = "SilentlyContinue"
... |
PowerShellCorpus/PoshCode/New-HyperVVM.ps1 | New-HyperVVM.ps1 | function New-HyperVVM {
param (
[string]$Hypervhost = "localhost",
[string]$Vm = "VM Courtesy of PowerShell",
[string]$location = "C:\\MyVirtualMachines\\$vm"
)
$wmiClassString = "\\\\" + $Hypervhost + "\\root\\virtualization:Msvm_VirtualSystemGlobalSettingData"
$wmiclass = [WMIClass]$wmiClassStri... |
PowerShellCorpus/PoshCode/Get-FileEncoding_4.ps1 | Get-FileEncoding_4.ps1 | <#
.SYNOPSIS
Gets file encoding.
.DESCRIPTION
The Get-FileEncoding function determines encoding by looking at Byte Order Mark (BOM).
Based on port of C# code from http://www.west-wind.com/Weblog/posts/197245.aspx
.EXAMPLE
Get-ChildItem *.ps1 | select FullName, @{n='Encoding';e={Get-FileEncoding $_.FullName}} | ... |
PowerShellCorpus/PoshCode/Autoload Module_1.ps1 | Autoload Module_1.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/Get-RemoteRegistry_3.ps1 | Get-RemoteRegistry_3.ps1 | #.SYNOPSIS
# Query the registry on a remote machine
#.NOTE
# You have to have access, and the remote registry service has to be running
#
# Version History:
# 3.0
# + updated to PowerShell 2
# + support pipeline parameter for path
# 2.1
# + Fixed a pasting bug
# + I added the ... |
PowerShellCorpus/PoshCode/Get-LastReboot.ps1 | Get-LastReboot.ps1 | Param (
[Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
[alias("Name","ComputerName")]$Computer=@($env:ComputerName),
[switch] $Output
)
process{
if (Test-Connection -ComputerName $Computer -Count 1 -Quiet){
write-host "Getting Uptime for $Computer" -foregroundcolor green... |
PowerShellCorpus/PoshCode/Start-Encryption_2.ps1 | Start-Encryption_2.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/Search-StartMenu.ps1 | Search-StartMenu.ps1 | ##############################################################################\n##\n## Search-StartMenu\n##\n## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/blog)\n##\n##############################################################################\n\n<#\n\n.SYNOPSIS\n\nSearch t... |
PowerShellCorpus/PoshCode/Set-Computername_13.ps1 | Set-Computername_13.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/CLR4 module.ps1 | CLR4 module.ps1 | function Start-CLR4 {
[CmdletBinding()]
param ( [string] $cmd )
if ($PSVersionTable.CLRVersion.Major -eq 4)
{
write-debug 'already running clr 4'
invoke-expression $cmd;
return
}
$RunActivationConfigPath = resolve-path ~ | Join-Path -ChildPath .CLR4PowerShell;
... |
PowerShellCorpus/PoshCode/Get-WebSite_2.ps1 | Get-WebSite_2.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/Snippet Compiler_2.ps1 | Snippet Compiler_2.ps1 | #Required 2.0
$def = $(if ((gi .).FullName -eq (gi .).Root) {
([string](gi .).Root).TrimEnd("\\")
}
else { (gi .).FullName }
)
##################################################################################################
$mnuOpen_Click= {
(New-Object Windows.Forms.O... |
PowerShellCorpus/PoshCode/New-Struct 3.ps1 | New-Struct 3.ps1 | function New-Struct {
#.Synopsis
# Creates Struct types from a list of types and properties
#.Description
# A wrapper for Add-Type to create struct types.
#.Example
# New-Struct Song {
# [string]$Artist
# [string]$Album
# [string]$Name
# [TimeSpan]$Length
# } -CreateConstructorFunction
#
#... |
PowerShellCorpus/PoshCode/Test-IsAdmin.ps1 | Test-IsAdmin.ps1 | Function Test-IsAdmin
{
<#
.SYNOPSIS
Function used to detect if current user is an Administrator.
.DESCRIPTION
Function used to detect if current user is an Administrator. Presents a menu if not an Administrator
.NOTES
Name: Test-IsAdmin
Author: Boe Pro... |
PowerShellCorpus/PoshCode/New-StoredProcFunction_3.ps1 | New-StoredProcFunction_3.ps1 | # New-StoredProcFunction.ps1
# Steven Murawski
# http://blog.usepowershell.com
# 04/08/2009
# Replaced the parsing of the stored procedure text and use Information_Schema.Parameters to get the parameter information
# Thanks to Chad Miller for the idea.
# Example: ./New-StoredProcFunction.ps1 'Data Source=MySql... |
PowerShellCorpus/PoshCode/Resolve-Aliases _1.7.ps1 | Resolve-Aliases _1.7.ps1 | #requires -version 2.0
## ResolveAliases Module v 1.6
########################################################################################################################
## Sample Use:
## Resolve-Aliases Script.ps1 | Set-Content Script.Resolved.ps1
## ls *.ps1 | Resolve-Aliases -Inplace
##############... |
PowerShellCorpus/PoshCode/Remove-MyOldComputers.ps1 | Remove-MyOldComputers.ps1 | ##
# Remove-MyOldComputers.ps1
#
# Makes certian assumptions about your computers naming scheme: mainly that all your
# computers are named as follows: {username}* I.E. bob1, bob-test, bob-server, etc
#
##
param (
[String] $Name=((whoami).Split('\\')[1]),
[Int32] $MaxDaysOld=20
)
$root = [ADSI]''
... |
PowerShellCorpus/PoshCode/Add new smtp_set prmary_2.ps1 | Add new smtp_set prmary_2.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/Compare-Drive_1.ps1 | Compare-Drive_1.ps1 | param($ComputerName1,$ComputerName2)
$a = gwmi win32_volume -filter "DriveType=3" -computername $ComputerName1 | where {@('Y:','Z:') -notcontains $_.DriveLetter} | select name, @{n='capacity'; e={[math]::truncate($_.Capacity/1GB)}}
$b = gwmi win32_volume -filter "DriveType=3" -computername $ComputerName2 | where ... |
PowerShellCorpus/PoshCode/Send-Mapi.ps1 | Send-Mapi.ps1 | ##############################################################################
#.AUTHOR
# Josh Einstein
# Einstein Technologies, LLC
##############################################################################
##############################################################################
#.SYNOPSIS
# Opens a... |
PowerShellCorpus/PoshCode/82bfeecc-3581-4dec-8684-4e98aef8a59a.ps1 | 82bfeecc-3581-4dec-8684-4e98aef8a59a.ps1 | # Enumerate fan speeds on an ESX host that is running WSMAN.
# This doesn't take advantage of CTP3's WSMAN cmdlets.
# Needs winrm installed.
$serverName = "your.server"
$user = "root"
$password = "password"
$x = [xml](winrm enumerate `
http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_NumericSensor `
"-... |
PowerShellCorpus/PoshCode/Format-Column 0.3.ps1 | Format-Column 0.3.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/Script-Object.ps1 | Script-Object.ps1 | #Copyright (c) 2011 Justin Dearing
#
#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, modify, merge, publish, dist... |
PowerShellCorpus/PoshCode/ESXi Config BackupScript_1.ps1 | ESXi Config BackupScript_1.ps1 | ###ESXi Configuration Backup Script
#DESCRIPION: This Script takes a CSV file with the hostname, username, and password of a list of ESXi servers, and backs up their configurations to a specified Destination
#USAGE: This script is meant to be run as a regular scheduled task or a pre-script for a backup job. There is ... |
PowerShellCorpus/PoshCode/get-serials.ps1 | get-serials.ps1 | <#
.SYNOPSIS
Get the BIOS serial numbers from computers in the domain.
.DESCRIPTION
Return a list of computers with their serial numbers. For Dell computers the Win32_BIOS.SerialNumber property
is the service tag of the computer. This identifies the computer on the Dell support site... |
PowerShellCorpus/PoshCode/bc7d5dc9-76a4-432e-ad15-2f3acae17658.ps1 | bc7d5dc9-76a4-432e-ad15-2f3acae17658.ps1 | param (
$UserName,
$FilePath,
[switch]$SaveCredential=$False,
[switch]$RdpSaveCredential=$False,
[switch]$DeleteCredential=$False,
[switch]$Help=$False
)
$ScriptFilenam = $MyInvocation.MyCommand.Name # ScriptFilename wo path.
$ScriptUnbArgs = $MyInvocation.UnboundArguments # UnNamed Arguments of the Po... |
PowerShellCorpus/PoshCode/ShowUI Text Converter.ps1 | ShowUI Text Converter.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/Get-App.ps1 | Get-App.ps1 |
## Get-App
## Attempt to resolve the path to an executable using Get-Command and the AppPaths registry key
##################################################################################################
## Example Usage:
## Get-App Notepad
## Finds notepad.exe using Get-Command
## Get-App pbrush
... |
PowerShellCorpus/PoshCode/Get-WebSite.ps1 | Get-WebSite.ps1 | function Get-WebSite {
<#
.SYNOPSIS
Retrieves information about a website.
.DESCRIPTION
Retrieves information about a website.
.PARAMETER Url
URL of the website to test access to.
.PARAMETER UseDefaultCredentials
Use the currently authenticated user's credentials
.PARAMETER Proxy
Us... |
PowerShellCorpus/PoshCode/PS2WCF_5.ps1 | PS2WCF_5.ps1 | <#
.SYNOPSIS
Functions to call WCF Services With PowerShell.
.NOTES
Version 1.2 11.02.2012
Requires Powershell v2 and .NET 3.5
Original version by Christian Glessner
Blog: http://www.iLoveSharePoint.com
Twitter: http://twitter.com/cglessner
Codeplex: http://codeplex.com/iLoveSharePoint
PowerS... |
PowerShellCorpus/PoshCode/Set Logfile lines.ps1 | Set Logfile lines.ps1 | ################################################################################
# This script will maintain the PS Transcript file at a fixed length and can be
# used to prevent such files, etc, from becoming too large. It is best placed in
# the $profile. Defaults to 10000 lines. Parameters allow use for other fi... |
PowerShellCorpus/PoshCode/Split-TextToLines Demo_2.ps1 | Split-TextToLines Demo_2.ps1 | # Variables
$viserver = Read-Host "Enter VI server name"
$cluster = Read-Host "Enter Cluster name"
$vmhelper = Read-Host "Enter VM_HELPER name"
Write-Host "Connecting to $viserver..."
Connect-VIServer $viserver -WarningAction:SilentlyContinue
# Get VM Hosts
$vmhosts = Get-Cluster $cluster -ErrorAction:Silent... |
PowerShellCorpus/PoshCode/Set vSphere CDP LinkDisc.ps1 | Set vSphere CDP LinkDisc.ps1 | function set-vSwitchLinkDiscovery {
Param (
#Switch to enable vSwitch Discovery On
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]$vSwitchName
#Host on which the vSwitch Resides
,[Parameter(Mandatory=$true,HelpMessage="")][string]$VMBackupDestination,
) #Param
#Va... |
PowerShellCorpus/PoshCode/01dbc242-a783-4249-9862-3fbf3231f7b6.ps1 | 01dbc242-a783-4249-9862-3fbf3231f7b6.ps1 | # Code to auto update the Address policy, GAL, OAB and storage groups and mailbox databases of an Exchange 2007 server by John McLear
# This code is good for hosting providers or people who wish to use lots of storage groups and mailbox databases.
#
# Thanks to Joel Bennett (Jaykul) for general scripting help and t... |
PowerShellCorpus/PoshCode/Get-InstalledProgram_v_4.ps1 | Get-InstalledProgram_v_4.ps1 | function Get-InstalledProgram() {
param (
[String[]]$Computer,
$User
)
#############################################################################################
if ($User) {$Connection = Get-Credential -Credential $User}
########################################################################################... |
PowerShellCorpus/PoshCode/Set-Domain_4.ps1 | Set-Domain_4.ps1 | function Set-Domain {
param( [switch]$help,
[string]$domain=$(read-host "Please specify the domain to join"),
[System.Management.Automation.PSCredential]$credential = $(Get-Crdential)
)
$usage = "`$cred = get-credential `n"
$usage += "Set-Domain -domain MyDomain -credential `$cred`n"
if ($help... |
PowerShellCorpus/PoshCode/Get-Tail.ps1 | Get-Tail.ps1 | # Name: Get-Tail.ps1
# Author: William Stacey
# Created: 02/22/2007
# Description: Gets the last N lines of a file. Does scan from end-of-file so works on large files. Also has a loop flag that prompts for refresh.
function Get-Tail([string]$path = $(throw "Path name must be specified."), [int]$count = 10, [bool... |
PowerShellCorpus/PoshCode/Copy-MAGig_1.ps1 | Copy-MAGig_1.ps1 | function Copy-MAGig
{
param(
[string]$src,
[string]$dest,
$exclude,
[int]$width = 100, # used with the -log switch to format the log,
[int]$ident = 2, # dito
[switch]$log, # if -verbose had a nice format and its output cou... |
PowerShellCorpus/PoshCode/1931a71c-ecb0-4b18-85ba-635d4034e7a1.ps1 | 1931a71c-ecb0-4b18-85ba-635d4034e7a1.ps1 | PARAM(
$location=$(throw "Make sure to specify a location for old machines to be imported")
)
$oldVM = Get-ChildItem "$location\\*.xml"
foreach($vm in $oldVM)
{
$vmGuid = [System.IO.Path]::GetFileNameWithoutExtension($vm.Name)
Invoke-Command -ScriptBlock {cmd /c "Mklink `"C:\\ProgramData\\Microsoft\\Windows... |
PowerShellCorpus/PoshCode/Profile Function.ps1 | Profile Function.ps1 | ########################################################
# This function will prompt the user asking if they want
# to start a transcript file. It will loop until the user
# types y or n. If the user selects y, the script will
# check to see if the transcript exists. If it doesn't
# it is created. If it does, the ... |
PowerShellCorpus/PoshCode/Update-VmFromTemplate.ps.ps1 | Update-VmFromTemplate.ps.ps1 | <#
.SYNOPSIS
Create a new VM from an imported template
.DESCRIPTION
This script will modify a VM on Hyper-V R2 that has been imported from an exported VM.
The current release of the HyperV module does not support the proper Import method, so
I don't implement that bit in t... |
PowerShellCorpus/PoshCode/Two ways get random pass.ps1 | Two ways get random pass.ps1 | #ugly way
function Get-RandomPassword {
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[int]$PasswordLength = "7"
)
$rnd = New-Object Random
$chr = @(33..125)
for ($i = 0; $i -lt $PasswordLength; $i++) {
$pas += [char]$chr[$rnd.Next(0, [int]$chr.Length)]
}
return $p... |
PowerShellCorpus/PoshCode/SearchZIP.psm1 .ps1 | SearchZIP.psm1 .ps1 | function SearchZIPfiles {
<#
.SYNOPSIS
Search for (filename) strings inside compressed ZIP or RAR files.
.DESCRIPTION
In any directory containing a large number of ZIP/RAR compressed Web Page files
this procedure will search each individual file name for simple text strings,
listing both the source RAR/ZIP fi... |
PowerShellCorpus/PoshCode/UIAutomation 1.6.ps1 | UIAutomation 1.6.ps1 | ## UI Automation v 1.6 -- REQUIRES the Reflection module (current version: http://poshcode.org/2480 )
##
# WASP 2.0 is getting closer, but this is 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.Invoke
... |
PowerShellCorpus/PoshCode/Get-Password.ps1 | Get-Password.ps1 | # ----------------------------------------------------------------------------------------------
# Get-Password PowerShell Script
#
# Author: John T Childers III
# Originally Written: 7/5/2011
# ***Important****
# Make sure to store this in a directory in that is a part of the path
# so that it you... |
PowerShellCorpus/PoshCode/Roll-Dice_2.ps1 | Roll-Dice_2.ps1 | # Roll-Dice.ps1
# Cody Bunch
# ProfessionalVMware.com
Begin {
$rand = New-Object System.Random
$dice = $rand.next(1,4)
}
Process {
if ( $_ -isnot [VMware.VimAutomation.Types.Snapshot] ) { continue }
if ($dice -gt 1) {
$_ | Remove-Snapshot -Confirm:$false
Write-Host "OH NOES! Snapshot $_ Has been... |
PowerShellCorpus/PoshCode/IP Scan_Local User admin.ps1 | IP Scan_Local User admin.ps1 | # The trigger
$obj = New-Object system.Net.NetworkInformation.Ping
100..200 | % { $ip = "10.1.1.$_"
$ping = $obj.send($ip,100)
write-host "." -noNewLine
if ($ping.status -eq "Success"){
C:\\Powershell\\Finduser.ps1 $ping.address.ipaddresstostring
}}
#--------------------------------
# Finduser.ps1
para... |
PowerShellCorpus/PoshCode/25a74c84-07ab-45d9-a031-0aaf972b8522.ps1 | 25a74c84-07ab-45d9-a031-0aaf972b8522.ps1 | select * from sys.dm_db_index_physical_stats(db_id('vCenter'),null,null,null,null)
order by avg_fragmentation_in_percent desc
|
PowerShellCorpus/PoshCode/Sendmail for PoSh V1.0.ps1 | Sendmail for PoSh V1.0.ps1 | #region vars
$global:maileditor = "C:\\Programme\\vim\\vim72\\vim.exe"
$global:encryption = "C:\\Programme\\GNU\\GnuPG\\gpg.exe"
$global:enckey = "s.patrick1982@gmail.com"
$global:tempmail = "C:\\temp\\psmail.txt"
$global:sigmail = "C:\\temp\\halten\\sig.txt"
$global:mailbody = ""
#endregion vars
#region init... |
PowerShellCorpus/PoshCode/Hack ESXi.ps1 | Hack ESXi.ps1 | $screen = " You see here a virtual switch. ------------ ------
#...........| |....|
--------------- ###------------ |...(|
|..%...........|########## ###-@...|
... |
PowerShellCorpus/PoshCode/Start-BootsTimer.ps1 | Start-BootsTimer.ps1 | function Start-BootsTimer {
#.Syntax
# Creates a stay-on-top countdown timer
#.Description
# A WPF borderless count-down timer, with audio/voice alarms and visual countdown + colored progress indication
#.Parameter EndMessage
# The message to be spoken by a voice when the time is up...
#.Parameter StartMessag... |
PowerShellCorpus/PoshCode/Find-Replace.ps1 | Find-Replace.ps1 | <#
.SYNOPSIS
Finds and Replaces multiple entries, in multiple files.
.DESCRIPTION
By default, performs an ordinal (case-sensitive and culture-insensitive) search to find an old value and replace it.
.PARAMETER Path
One or more files Paths to process. Excepts values from the Pipeline. Will except the output fr... |
PowerShellCorpus/PoshCode/sudo for Powershell_2.ps1 | sudo for Powershell_2.ps1 | # sudo.ps1
#
# Authors: pezhore, mrigns, This guy: http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell
# Other powershell peoples.
#
# Sources:
# http://tsukasa.jidder.de/blog/2008/03/15/scripting-sudo-with-powershell
# http://www.ainotenshi.org/%E2%80%98sudo%E2%80%99-for... |
PowerShellCorpus/PoshCode/Findup_3.ps1 | Findup_3.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 Findup
{
public class FileInfoExt
{
public FileInfo... |
PowerShellCorpus/PoshCode/Get-MX.ps1 | Get-MX.ps1 | #Returns the priority mail server (SMTP) for a particular email address.
function Get-MX {
param([string] $domain = $( Throw "Query required in the format domain.com or email@domain.com.") )
#rip domain out of full email address if necessary:
if ($domain.IndexOf("@")) { $domain = $domain.SubString($domain.Inde... |
PowerShellCorpus/PoshCode/LDAPLogging_1.ps1 | LDAPLogging_1.ps1 | \nfunction Private:Configure-Logging {\n<#\n .SYNOPSIS\n Enables, disables or view current LDAP Logging settings on a domain controller.\n\n .DESCRIPTION\n Enables, disables or view current LDAP Logging settings on a domain controller.\n \n Use one of the following aliases:\n \n Get-LDAPLo... |
PowerShellCorpus/PoshCode/Add-Identity.ps1 | Add-Identity.ps1 | param(
[Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
[alias("Name","ComputerName")] $Computer = @($env:computername),
[string] $NTDomain = ($env:UserDomain),
[string[]] $LocalGroups = @("Administrators"),
[string[]] $Identities, # can be domain user or group
[switch] $Outpu... |
PowerShellCorpus/PoshCode/Out-Voice 1.2.ps1 | Out-Voice 1.2.ps1 | # ---------------------------------------------------------------------------
## <Script>
## <Author>
## Joel "Jaykul" Bennett
## </Author>
## <Description>
## Outputs text as spoken words
## </Description>
## <Usage>
## Out-Speech "Hello World"
## </Usage>
## </Script>
# -----------------------------------... |
PowerShellCorpus/PoshCode/Get-Hostname_5.ps1 | Get-Hostname_5.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/Start-Demo 3.3.2.ps1 | Start-Demo 3.3.2.ps1 | ## Start-Demo.ps1
##################################################################################################
## This is an overhaul of Jeffrey Snover's original Start-Demo script by Joel "Jaykul" Bennett
##
## I've switched it to using ReadKey instead of ReadLine (you don't have to hit Enter each time)
## ... |
PowerShellCorpus/PoshCode/InvokeCSharp.ps1 | InvokeCSharp.ps1 | #< #
#.Synopsis
@@# Create a class instance and/or invoke a method on C# source code.
@@# For details, see:
@@# http://vincenth.net/blog/archive/2009/10/27/call-inline-c-from-powershell-with-invokecsharp.aspx
#.Description
# This function compiles the provided C# source code (only if necessary, compiled
... |
PowerShellCorpus/PoshCode/Remove Duplicate Notes.ps1 | Remove Duplicate Notes.ps1 | # remove outlook duplicate notes and put the removed note in a file
$outlook = new-object -comobject outlook.application
$session = $outlook.session
$session.logon()
$olFoldersEnum = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$notes = $session.getdefaultfolder($olFoldersEnum::olFolderNote... |
PowerShellCorpus/PoshCode/Get VMware Information_1.ps1 | Get VMware Information_1.ps1 | Connect-VIServer YOURSERVER
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Addsheet = $Excel.sheets.Add()
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(1,1) = "Name"
$Sheet.Cells.Item(1,2) = "Power State"
$Sheet.Cells.Item(1,3) = "Description"
$Sheet... |
PowerShellCorpus/PoshCode/Get-VMHostNetworks_1.ps1 | Get-VMHostNetworks_1.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/Citrix-Functions.ps1 | Citrix-Functions.ps1 | #########################################
#### Citrix Farm Functions ####
#########################################
# Get Citrix Farm
function Get-CitrixFarm{
param($Server)
$type = [System.Type]::GetTypeFromProgID("MetaframeCOM.MetaframeFarm",$Server)
$mfarm = [system.Activator]::CreateIns... |
PowerShellCorpus/PoshCode/Get-Parameter_1.ps1 | Get-Parameter_1.ps1 | function Get-Parameter ($Cmdlet) {
foreach ($paramset in (Get-Command $Cmdlet).ParameterSets){
$Output = @()
foreach ($param in $paramset.Parameters) {
$process = "" | Select-Object Name, ParameterSet, Aliases, IsMandatory, CommonParameter
$process.Name = $param.Name
if ( $paramset.name -eq "__AllPa... |
PowerShellCorpus/PoshCode/Test-GroupMembership.ps1 | Test-GroupMembership.ps1 | Function Test-GroupMembership {
Param($user,$group)
Get-QADUser $user | select memberof | %{
$result = $false
foreach ($i in $_.memberof) {
if ((Get-QADGroup $i).name -match $group){
$result = $true
break
}
}
$obj = "" | select Name,Group,IsMember
$obj.Name = $user
$obj.Group = $... |
PowerShellCorpus/PoshCode/Update VM Tools.ps1 | Update VM Tools.ps1 | ########################################################
#connect to VirtualCenter server (i.e. virtual-center-1)
if ($args[0] -eq $null)
{$hostName = Read-Host "What host do you want to connect to?"}
else
{$hostName = $args[0]}
#connect to selected Virtualcenter or host server
Connect-VIServer $hostName
... |
PowerShellCorpus/PoshCode/LetterDiamondOneliner v3.ps1 | LetterDiamondOneliner v3.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/Get-Parameter 1.1.ps1 | Get-Parameter 1.1.ps1 | function Get-Parameter
{
[OutputType('System.String')]
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[String]$Command,
[Parameter(Position=1)]
[String[]]$Name=@('*'),
[Parameter()]
[Validate... |
PowerShellCorpus/PoshCode/List AD Computers CSV.ps1 | List AD Computers CSV.ps1 | $datetime = Get-Date -Format "yyMMdd-HHmm"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
[string]$DomainName = $objDomain.name
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=computer)")
$Results ... |
PowerShellCorpus/PoshCode/WhoIs.ps1 | WhoIs.ps1 | param([String] $DomainName = '192.168.0.1')
$socket = New-Object System.Net.Sockets.Socket ([System.Net.Sockets.AddressFamily]::InterNetwork, [System.Net.Sockets.SocketType]::Stream, [System.Net.Sockets.ProtocolType]::Tcp)
$Socket.Connect('whois.arin.net', 43) | out-null
$bytes = [System.Text.Encoding]::ASCII.GetB... |
PowerShellCorpus/PoshCode/Protect-Variable.ps1 | Protect-Variable.ps1 | function Protect-Variable {
param(
[Parameter(Mandatory=$true,Position=0)][String]$Name, [Int]$Scope = 1,
[Parameter(ParameterSetName="ValidateScriptBlock")][ScriptBlock]$ScriptBlock,
[Parameter(ParameterSetName="ValidateCount")][Int]$MinCount,
[Parameter(ParameterSetName="ValidateCount")][Int]$MaxCount,
[Paramet... |
PowerShellCorpus/PoshCode/Get-FailingDrive.ps1 | Get-FailingDrive.ps1 | Function Get-FailingDrive {
<#
.SYNOPSIS
Checks for any potentially failing drives and reports back drive information.
.DESCRIPTION
Checks for any potentially failing drives and reports back drive information. This only works
against local hard drives using SMART technology. Reason values and th... |
PowerShellCorpus/PoshCode/Re-IP VMs.ps1 | Re-IP VMs.ps1 | foreach ($entry in (import-csv "spreadsheet.csv")) {
$ipScript = @"
`$NetworkConfig = Get-WmiObject -Class Win32_NetworkAdapterConfiguration
`$NicAdapter = `$NetworkConfig | where {`$_.DHCPEnabled -eq "True"}
`$NicAdapter.EnableStatic('$entry.IP','$entry.Netmask')
`$NicAdapter.SetGateways('$entry.Gateway')
... |
PowerShellCorpus/PoshCode/Compare-TwitterNames_2.ps1 | Compare-TwitterNames_2.ps1 | #This script will compare the names of the people you follow on Twitter
#and the people following you. It returns a comparison object consisting
#of the Twitter name of a subject and a side indicator -
#"<=" means that you are following a subject who is not following you,
#"=>" means that you are followed by so... |
PowerShellCorpus/PoshCode/Get-PDC09Videos_1.ps1 | Get-PDC09Videos_1.ps1 | #requires -version 2.0
PARAM (
[Parameter(Position=1, Mandatory=$true)]
[ValidateSet("wmv","wmvhigh","ppt")] # the "mp4" files aren't there yet
[String]$MediaType,
[string]$Destination = $PWD
)
Import-Module BitsTransfer
Push-Location $Destination
$Extension = $(switch -wildcard($MediaType){"wmv*"... |
PowerShellCorpus/PoshCode/sophos_mrupdate.ps1 | sophos_mrupdate.ps1 | <#
.SYNOPSIS
Updates the Sophos Message Relay configuration.
.DESCRIPTION
Points the local Message Router service to a new parent relay server.
.PARAMETER mrinit
The mrinit.conf file to use.
.PARAMETER loglevel
The current loglevel (used by the Log function).
Defaults to 'information' (debug m... |
PowerShellCorpus/PoshCode/List AD Computers XLS.ps1 | List AD Computers XLS.ps1 | # Create a new Excel object using COM
$Excel = New-Object -ComObject Excel.Application
$Excel.visible = $True
# WMI Class variables
$WMI_CSP = "Win32_ComputerSystemProduct"
$WMI_CS = "Win32_ComputerSystem"
$WMI_Disk = "Win32_LogicalDisk"
$WMI_OS = "Win32_OperatingSystem"
$WMI_Proc = "Win32_Processor"
# Set... |
PowerShellCorpus/PoshCode/1c3a8f71-b8a5-455c-bc04-31657019f3d5.ps1 | 1c3a8f71-b8a5-455c-bc04-31657019f3d5.ps1 | #Params is file or folder
param([string] $PSUnitTestFile, [string] $Category ="All", [switch] $ShowReportInBrowser)
Write-Debug "PSUnit.Run.ps1: Parameter `$PSUnitTestFile=`"$PSUnitTestFile`""
Write-Debug "PSUnit.Run.ps1: Parameter `$Category=`"$Category`""
#Don't run the script with an empty path to test file
... |
PowerShellCorpus/PoshCode/Get-MailAttachment.ps1 | Get-MailAttachment.ps1 | param([Microsoft.Exchange.WebServices.Data.FileAttachment]$attachment)
"Downloading Attachment"
$attachment.Load()
"Done"
$path = "C:\\temp\\"+$attachment.Name
"Writing to $path"
set-content -value $mm[1].Attachments[0].Content -enc byte -path $path
"Done"
ii $path
|
PowerShellCorpus/PoshCode/Hostprofile Update GUI.ps1 | Hostprofile Update GUI.ps1 | ################################################################################################################
#
# Purpose: Host Profile Update
# Author: David Chung
#
# Ver 1.0 - 09/22/2011 Initial Script
# Ver 1.1 - 09/26/2011 Added Full GUI support (Primal Forms)
# Ver 1.2 - 09/26/2011 Enabled User an... |
PowerShellCorpus/PoshCode/Get-Scope_1.ps1 | Get-Scope_1.ps1 | function Get-Scope{
$rtnScope = 0
$global:scope = $false
$scope = $true
while($($ErrorActionPreference = "silentlycontinue"; switch((get-Variable -Name scope -Scope $rtnScope).value){$null{$true} $true{$true} $false{$ErrorActionPreference = "continue"; return ($rtnScope - 1)}})){
$rtnScope+... |
PowerShellCorpus/PoshCode/Get-DatastoreMostFree.ps1 | Get-DatastoreMostFree.ps1 | #Parameter- Name of the VMware cluster the VM will be assigned to
function Get-DatastoreMostFree ($Cluster, [switch] $Second)
{
<#
.SYNOPSIS
Return the datastore in the cluster with the most unprovisioned disk space. This takes thin provisioning into account.
.DESCRIPTION
Queries all the datastores in the clu... |
PowerShellCorpus/PoshCode/Out-Html_2.ps1 | Out-Html_2.ps1 | ################################################################################
# Out-HTML - converts cmdlets help to HTML format
# Based on Out-wiki by Dimitry Sotnikov (http://dmitrysotnikov.wordpress.com/2008/08/18/out-wiki-convert-powershell-help-to-wiki-format/)
#
# Modify the invocation line at the bottom of... |
PowerShellCorpus/PoshCode/ISE-CopyOutPutToEditor_1.ps1 | ISE-CopyOutPutToEditor_1.ps1 | function ISE-CopyOutPutToEditor () {
$count = $psise.CurrentOpenedRunspace.OpenedFiles.count
$psIse.CurrentOpenedRunspace.OpenedFiles.Add()
$Newfile = $psIse.CurrentOpenedRunspace.OpenedFiles[$count]
$Newfile.Editor.Text = $psIse.CurrentOpenedRunspace.output.Text
$Newfile.Editor.Focus()
}
$nu... |
PowerShellCorpus/PoshCode/count-object_1.ps1 | count-object_1.ps1 | #a function to count how many items there are, whether its an array, a collection, or actually just
# a single no array/non list/non collection object in which case it would be 1
function count-object ($InputObject)
{
if ($inputobject -eq $Null ) { return 0}
if ($inputobject -is [system.array]) { return $inputob... |
PowerShellCorpus/PoshCode/Get-DellWarranty_2.ps1 | Get-DellWarranty_2.ps1 | function Get-DellWarranty {
<#
.Synopsis
Provides warranty information for one or more Dell service tags.
.Description
Queries the Dell Website for a list of service tags and returns the warranty information as a custom object.
If a service tag has multiple warranties, they are... |
PowerShellCorpus/PoshCode/NTFS ACLs Folder Tree.ps1 | NTFS ACLs Folder Tree.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/New-SelfRestartingTask_1.ps1 | New-SelfRestartingTask_1.ps1 | function New-SelfRestartingTask {
<#
.Notes
For production use you should consider investigating more specific matching in the Query clause.
There are many possibilities here: you could watch for instances of a process with specific command-line parameters, or a certain caption, etc. Or, you could match again... |
PowerShellCorpus/PoshCode/Import-Asup.ps1 | Import-Asup.ps1 | Function Import-ASUP
{
param(
[string]
$Path
)
Begin {
Function ConvertTo-Bool($bool) {
switch ($bool) {
"yes" {return $true}
"true" {return $true}
"enabled" {return $true}
"no" {... |
PowerShellCorpus/PoshCode/AnalizeScript.ps1 | AnalizeScript.ps1 | <#
.SYNOPSIS
Analyzes script and gives starting lines & columns of script components
.DESCRIPTION
AnalizeScript opens a dialog box for user selection; checks that input is
a powershell script; parses and agrigates the script components into the
following tokens:
Unknown(s)
Command(s)... |
PowerShellCorpus/PoshCode/Get-NestedGroups_2.ps1 | Get-NestedGroups_2.ps1 | <#
.SYNOPSIS
Enumerate all AD group memberships of an account (including nested membership).
.DESCRIPTION
This script will return all the AD groups an account is member of.
.PARAMETER UserName
The username whose group memberships to find.
.EXAMPLE
.\\Get-NestedGroups.ps1 'johndoe'
Name ... |
PowerShellCorpus/PoshCode/ConvertTo-Hex_11.ps1 | ConvertTo-Hex_11.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/Search-NetworkService.ps1 | Search-NetworkService.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/New-Script 2.ps1 | New-Script 2.ps1 | ## New-Script function
## Creates a new script from the most recent commands in history
##################################################################################################
## Example Usage:
## New-Script ScriptName 4
## creates a script from the most recent four commands
## New-Script... |
PowerShellCorpus/PoshCode/Start-rdp_4.ps1 | Start-rdp_4.ps1 | \nFunction Global:Start-RDP {\n<#\n .Synopsis\n This Cmdlet starts a microsoft terminal session against the hostname provided.\n \n it is possible to collect credential information from a PSCredential file saved on the disk\n \n .Description \n This cmdlet starts a Microsoft terminal sesion against the hostname pro... |
PowerShellCorpus/PoshCode/Convert-StringSID_2.ps1 | Convert-StringSID_2.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/Set-Computername_4.ps1 | Set-Computername_4.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/Get-HtmlHelp_3.ps1 | Get-HtmlHelp_3.ps1 | Hello,
I wanted to reach out to inquire about the possibility of advertising on your blog in the form of sponsored guest posts.
Either I can have content written or you can write content that is relevant to your audience and helps to promote our client's service. We then pay for that post and the opportunity to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.