full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PoshCode/Get-ShortenedURL.ps1 | Get-ShortenedURL.ps1 | Function Get-ShortenedURL {
<#
.SYNOPSIS
Get-ShortenedURL
Author: Chris Campbell (@obscuresec)
License: BSD 3-Clause
.DESCRIPTION
A function that returns the actual URL from a http redirect.
.PARAMETER $ShortenedURL
Specifies the shortened URL.
.EXAMPLE
PS C:... |
PowerShellCorpus/PoshCode/Report-RecipientCounts.ps1 | Report-RecipientCounts.ps1 | <#
.SYNOPSIS
Report-RecipientCounts.ps1
Keep a running total of daily recipient count distribution.
.DESCRIPTION
Keep a running total of daily recipient count distribution.
.PARAMETER Days
The number of days back to examine logs.
Default = 1 (Yesterday)
.EXAMPLE
Report-R... |
PowerShellCorpus/PoshCode/Services Auto NotRunning_1.ps1 | Services Auto NotRunning_1.ps1 | #LazyWinAdmin.com
Get-WmiObject Win32_Service -ComputerName . |`
where {($_.startmode -like "*auto*") -and `
($_.state -notlike "*running*")}|`
select DisplayName,Name,StartMode,State|ft -AutoSize
|
PowerShellCorpus/PoshCode/Begin Block.ps1 | Begin Block.ps1 | Begin {
#VMware VM Host (ESX) UUID
$VMHost_UUID = @{
Name = "VMHost_UUID"
Expression = { $_.Summary.Hardware.Uuid }
}
#XenServer Host UUID
$XenHost_UUID = @{
Name = "XenHost_UUID"
Expression = { $_.Uuid }
}
}
|
PowerShellCorpus/PoshCode/ConvertTo-Hex_6.ps1 | ConvertTo-Hex_6.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/Convert-ToCHexString_5.ps1 | Convert-ToCHexString_5.ps1 | function Convert-ToCHexString
{
param ([String] $str)
$ans = ''
[System.Text.Encoding]::ASCII.GetBytes($str) | % { $ans += "0x{0:X2}, " -f $_ }
return $ans.Trim(' ',',')
}
|
PowerShellCorpus/PoshCode/Timespan SMTP Headers.ps1 | Timespan SMTP Headers.ps1 | $hdr_txt = gc ./hdr.txt
$rec_hdr_regex = [regex]"^Received\\:\\sfrom\\s(.+?)\\sby\\s(.+?)\\;\\s(.+?\\d\\d\\:\\d\\d\\:\\d\\d\\s[+|-]\\d{4})"
$from_hdr = $hdr_txt | select-string "^From\\:\\s.+$"
$rec_block = $hdr_txt[0..$($from_hdr.linenumber -2)]
$rec_lines = $rec_block | select-string "^Received\\:\\sfrom"
... |
PowerShellCorpus/PoshCode/Pause_1.ps1 | Pause_1.ps1 | function Pause ($Message = "Press any key to continue...")
{
Write-Host -NoNewline $Message
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host ""
}
|
PowerShellCorpus/PoshCode/Select-Random v2.0.ps1 | Select-Random v2.0.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Joel "Jaykul" Bennett
### </Author>
### <Description>
### Selects a random element from the collection either passed as a parameter or input via the pipeline.
### If the collection is passed in as an argum... |
PowerShellCorpus/PoshCode/FTP upload_5.ps1 | FTP upload_5.ps1 | @charset "utf-8";
/*
Credit:http://www.templatemo.com
*/
body {
margin: 0px;
padding: 0px;
color: #c2bead;
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
line-height: 1.5em;
background-color: #2f2e28;
background-image: url(images/templatemo_body.jpg);
background-repeat: repeat-y;
bac... |
PowerShellCorpus/PoshCode/Edit-RDP.ps1 | Edit-RDP.ps1 | ########################################################################################################################
# NAME
# Edit-RDP
#
# SYNOPSIS
# Opens a RDP file for editing.
#
# SYNTAX
# Edit-RDP [-Path] <string>
#
# DETAILED DESCRIPTION
# The Edit-RDP cmdlet opens an existing RDP f... |
PowerShellCorpus/PoshCode/Lead Systems Engineer.ps1 | Lead Systems Engineer.ps1 | <#
Author: Matt Schmitt
Date: 11/28/12
Version: 1.0
From: USA
Email: ithink2020@gmail.com
Website: http://about.me/schmittmatt
Twitter: @MatthewASchmitt
Description
A script for forwarding and unforwarding email for users in Office 365.
#>
Import-Module ActiveD... |
PowerShellCorpus/PoshCode/Download DefragTools _1.ps1 | Download DefragTools _1.ps1 | #requires -version 2.0
<#
.Synopsis
Downloads Channel 9 Defrag Tool Episode Video
.DESCRIPTION
Downloads Channel 9 Defrag Tool Episode Video in the format selected and to a given path.
.EXAMPLE
Downloads all shows in WMV format to the default Downloads Folder for the user.
Get-DefragToolsShow -All... |
PowerShellCorpus/PoshCode/Find-Abbreviation.ps1 | Find-Abbreviation.ps1 | # Name : Find-Abbreviation.ps1
# Author: David "Makovec" Moravec
# Web : http://www.powershell.cz
# Email : powershell.cz@googlemail.com
#
# Description: Finds meaning of given abbreviation
# : Uses HttpRest http://poshcode.org/787
#
# Version: 0.1
# History:
# v0.1 - (add) basic functionality
... |
PowerShellCorpus/PoshCode/Start-BootsTimer_1.ps1 | Start-BootsTimer_1.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/Get_Set Signature 2.4.ps1 | Get_Set Signature 2.4.ps1 | #Requires -version 2.0
## Authenticode.psm1 updated for PowerShell 2.0 (with time stamping)
####################################################################################################
## Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature cmdlets
## These properly parse paths, so th... |
PowerShellCorpus/PoshCode/c0b827b7-ab4f-4cce-93be-c140388d2469.ps1 | c0b827b7-ab4f-4cce-93be-c140388d2469.ps1 | ################################################################################################################
#
# NAME
# Copy-Data
#
# SYNOPSIS
# Copy Data between Folders including a Progressbar
#
# SYNTAX
# Copy-Data [Source <PathToSource>] [Destination <PathToDestination>] [-Confirm] [-Recu... |
PowerShellCorpus/PoshCode/Exch07 Snd_Rec Report.ps1 | Exch07 Snd_Rec Report.ps1 | # Get the start date for the tracking log search
$Start = (Get-Date -Hour 00 -Minute 00 -Second 00).AddDays(-1)
# Get the end date for the tracking log search
$End = (Get-Date -Hour 23 -Minute 59 -Second 59).AddDays(-1)
#Create a date for the csv file that this will get spit into
$date = get-date -Format MM-dd... |
PowerShellCorpus/PoshCode/Start-Encryption_4.ps1 | Start-Encryption_4.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/Audit NTFS on Shares_2.ps1 | Audit NTFS on Shares_2.ps1 | $Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$wSheet = $Excel.Worksheets.Item(1)
$wSheet.Cells.item(1,1) = "Folder Path:"
$wSheet.Cells.Item(1,2) = "Users/Groups:"
$wSheet.Cells.Item(1,3) = "Permissions:"
$wSheet.Cells.Item(1,4) = "Permissions Inherited:"
... |
PowerShellCorpus/PoshCode/Start-ISE.ps1 | Start-ISE.ps1 | function Start-ISE ()
{
<#
.synopsis
Load some file into ISE
.Description
Load some file into ISE
.Parameter fileObjOrFileName
file to be loaded
.ReturnValue
$null
.Notes
Author: bernd kriszio
e-mail: bkriszio@googlemail.com
... |
PowerShellCorpus/PoshCode/Compare-Drive.ps1 | Compare-Drive.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/Get-LeaderBoard_3.ps1 | Get-LeaderBoard_3.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. To see the output
in a table, you must pipe to "format-table -autosi... |
PowerShellCorpus/PoshCode/Trace-Route.ps1 | Trace-Route.ps1 | function Trace-Route
{
param(
# The URL to trace
[Parameter(Mandatory=$true)]
[Uri]$Url,
# The timeout for the request, in milliseconds
[Timespan]$Timeout = "0:0:0.25",
# The maximum number of hops for the trace route
[Int]$MaximumHops = 32
)
process {
Invoke-Expressio... |
PowerShellCorpus/PoshCode/Get-EventLogBackup.ps1 | Get-EventLogBackup.ps1 | Param($BackupLocation,$list,$FromAD,[switch]$clear)
# For more info read the following blog entry
# http://www.bsonposh.com/modules/wordpress/?p=41
function Get-ADComputers{
$filter = "(&(objectcategory=computer))"
$root = [ADSI]""
$props = "dNSHostName","sAMAccountName"
$Searcher = new-Object Sy... |
PowerShellCorpus/PoshCode/SharpSsh 3.ps1 | SharpSsh 3.ps1 | #requires -version 2.0
## A simple SSH Scripting module for PowerShell
## History:
## v1 - Initial Script
## v2 - Capture default prompt in New-SshSession
## v3 - Update to advanced functions, require 2.0, and add basic help
## USING the binaries from:
## http://downloads.sourceforge.net/sharpssh/SharpSSH-1.1.... |
PowerShellCorpus/PoshCode/Get-ADGroupMembers_1.ps1 | Get-ADGroupMembers_1.ps1 | Function Get-ADGroupMembers
{
<#
.SYNOPSIS
Return a collection of users in an ActiveDirectory group.
.DESCRIPTION
This function returns an object that contains all the properties of a user object. This function
works for small groups as well as groups in ex... |
PowerShellCorpus/PoshCode/Chassis Type_2.ps1 | Chassis Type_2.ps1 | $system = Get-WMIObject -class Win32_systemenclosure
$type = $system.chassistypes
Switch ($Type)
{
"1" {"Chassis type is: $Type - Other"}
"2" {"Chassis type is: $type - Virtual Machine"}
"3" {"Chassis type is: $type - Desktop"}
"4" {"Chassis type is: $type - Low Profile Desk... |
PowerShellCorpus/PoshCode/Invoke-SqlCmd_4.ps1 | Invoke-SqlCmd_4.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
.INPUTS
None
You cannot pipe objects to Invoke-Sqlcmd2
.OUTPUTS
System.Data.DataTable
.EXA... |
PowerShellCorpus/PoshCode/Get-Scope.ps1 | Get-Scope.ps1 | function Get-Scope {
#.Synopsis
# Determine the scope of execution (are you in a module? how many scope layers deep are you?)
#.Parameter Invocation
# In order to correctly determine the scope, this function requires that you pass in the $MyInvocation variable when you call it.
#.Parameter ToHost
# If you jus... |
PowerShellCorpus/PoshCode/Out-Report.ps1 | Out-Report.ps1 | #Depends on Microsoft Report Viewer Redistributable and ReportExporters
#ReportExporters available at http://www.codeproject.com/KB/reporting-services/ReportExporters_WinForms.aspx
#Download demo version of ReportExporters for compiled dlls
#Tested with Microsoft Report Viewer 2008 SP1 Redistributable, although 2005... |
PowerShellCorpus/PoshCode/AD Recycle Bin - Restore.ps1 | AD Recycle Bin - Restore.ps1 | ' Script: Create_Restore.vbs
' Purpose: This script will graphically create a Powershell script based on user input, the powershell script can be run to restore deleted AD Objects
' Author: Paperclips
' Email: magiconion_M@hotmail.com
' Date: Feb 2011
' Comments: Creating a ps1 script to rest... |
PowerShellCorpus/PoshCode/4aea4469-64f1-4f01-9c7f-054ecd61a063.ps1 | 4aea4469-64f1-4f01-9c7f-054ecd61a063.ps1 | function Get-VCTime() {
return (Get-View "ServiceInstance-ServiceInstance").CurrentTime()
}
$lastCheckTime = Get-VCTime
while ($true)
{
$modifiedVMs = @()
$freshEventsStartTime = $lastCheckTime
$lastCheckTime = Get-VCTime
# Get all the VM network edit events
foreach ($event in Get... |
PowerShellCorpus/PoshCode/chkhash_17.ps1 | chkhash_17.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/c36fba47-49ce-4fb7-8194-54b0294b4a9b.ps1 | c36fba47-49ce-4fb7-8194-54b0294b4a9b.ps1 | function Write-Host
{
<#
.SYNOPSIS
Replacement of Write-Host function to work around an issue where use of Write-Host can
cause an eventual problem with launching EXEs from within the same Powershell session.
.DESCRIPTION
This Write-Host replacement can act as a temporary wo... |
PowerShellCorpus/PoshCode/Get-Selection.ps1 | Get-Selection.ps1 | function Write-Choice {
param($prompt, $choice)
write-host -n "["
write-host -n -f yellow $prompt
write-host "]", $choice
Write-Output $prompt
}
function Get-Selection {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,HelpMessage="Choices")]
[Object]
$choice,
[Parameter(... |
PowerShellCorpus/PoshCode/CDRom Open__Close.ps1 | CDRom Open__Close.ps1 | using System;
using System.Reflection;
using System.Globalization;
using System.Runtime.InteropServices;
[assembly: AssemblyVersion("2.0.0.0")]
namespace CDRomOpenClose {
internal static class WinAPI {
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
internal static extern IntPtr CreateFile(... |
PowerShellCorpus/PoshCode/Add-SqlTable_1.ps1 | Add-SqlTable_1.ps1 | try {add-type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" -EA Stop}
catch {add-type -AssemblyName "Microsoft.SqlServer.Smo"}
#######################
function Get-SqlType
{
param([string]$TypeName)
switch ($TypeName)
{
'Bool... |
PowerShellCorpus/PoshCode/Brushes.ps1 | Brushes.ps1 | $frmMain_OnLoad= {
$m_BrushSize = New-Object Drawing.Rectangle(0, 0, $picDemo.Width, $picDemo.Height)
$wm = [Drawing.Drawing2D.WrapMode]
$cboWraM.Items.AddRange(@($wm::Clamp, $wm::Tile, $wm::TileFlipX, $wm::TileFlipY, $wm::TileFlipXY))
$cboWraM.SelectedIndex = 0
[int]$maxHatchStyle = 53
for ($i ... |
PowerShellCorpus/PoshCode/Get-GrowthRate_2.ps1 | Get-GrowthRate_2.ps1 | function Get-GrowthRate {
param( $Start, $End, $Period )
@@ $rate = [math]::Abs( [math]::Pow( ( $End / $Start ),( 1 / ($Period - 1 ) ) - 1 )
"{0:P}" -f $rate
}
|
PowerShellCorpus/PoshCode/Enter-Module.ps1 | Enter-Module.ps1 | ##############################################################################\n##\n## Enter-Module\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\nLets you ex... |
PowerShellCorpus/PoshCode/Findup_31.ps1 | Findup_31.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/Get-WebFile _2.7.ps1 | Get-WebFile _2.7.ps1 | ## Function Get-WebFile (aka wget for PowerShell)
## Author: Joel Bennett and
## Peter Kriegel http://www.admin-source.de
## Original : http://poshcode.org/417
##
##############################################################################################################
## Downloads a file or page from the web... |
PowerShellCorpus/PoshCode/New-CodeSigningCert_1.ps1 | New-CodeSigningCert_1.ps1 | ## New-CodeSigningCert.ps1
########################################################################################################################
## Does the setup needed to self-sign PowerShell scripts ...
## Generates a "test" self-signed root Certificate Authority
## And then generates a code-signing certific... |
PowerShellCorpus/PoshCode/RSS Enclosure Downloader_1.ps1 | RSS Enclosure Downloader_1.ps1 | # author: Alexander Grofl
# http://www.therightstuff.de/2008/07/25/RSS+Enclosure+Downloader+In+PowerShell.aspx
$feed=[xml](New-Object System.Net.WebClient).DownloadString("http://the/rss/feed/url")
foreach($i in $feed.rss.channel.item) {
$url = New-Object System.Uri($i.enclosure.url)
$url.ToString()
$url.Se... |
PowerShellCorpus/PoshCode/ESXiMgmt module sample 5.ps1 | ESXiMgmt module sample 5.ps1 | #######################################################################################################################
# File: ESXiMgmt_register_all_virtual_machines_sample.ps1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/Get-ExcludedCsprojJavasc_1.ps1 | Get-ExcludedCsprojJavasc_1.ps1 | param(
$projectDirectoryName = "MyProject"
)
$thisDir = Split-Path $MyInvocation.MyCommand.Path
$projectDir = "$thisDir/../$projectDirectoryName"
$csproj = [xml](cat $projectDir/*.csproj)
$csprojScripts = $csproj.Project.ItemGroup.Content.Include | ? {$_ -match '\\.js$'}
"$($csprojScripts.length) scrip... |
PowerShellCorpus/PoshCode/TabExpansion_14.ps1 | TabExpansion_14.ps1 | ## Tab-Completion
#################
## Please dot souce this script file.
## In first loading, it may take a several minutes, in order to generate ProgIDs and TypeNames list.
##
## What this can do is:
##
## [datetime]::n<tab>
## [datetime]::now.d<tab>
## $a = New-Object "Int32[,]" 2,3; $b = "PowerShell","Pow... |
PowerShellCorpus/PoshCode/Modified WOL impl..ps1 | Modified WOL impl..ps1 | function SendUdpWol {
#Packet construction reference:
#- http://wiki.wireshark.org/WakeOnLAN
#- http://en.wikipedia.org/wiki/Wake-on-LAN
#
#This code is a modified version of:
# - http://thepowershellguy.com/blogs/posh/archive/2007/04/01/powershell-wake-on-lan-script.aspx
param (
[parameter(Mandat... |
PowerShellCorpus/PoshCode/WindowsInstallPoint.ps1 | WindowsInstallPoint.ps1 | function Initialize-WindowsInstallPoint {
<#
.SYNOPSIS
Initializes a drive to become a Windows OS install point.
.DESCRIPTION
The Initialize-WindowsInstallPoint function uses the "diskpart" utility to wipe, partition, and format a local or removable drive.
The "bootsect" tool processes the bootmgr all... |
PowerShellCorpus/PoshCode/Compare Reg Keys.ps1 | Compare Reg Keys.ps1 | <#
.SYNOPSIS
Compares Registry Key Properties and subkeys across multiple computers
.DESCRIPTION
The function Get-AllRegKey will recurse down from a given key, returning an array having
the key's properties, subkeys, and their properties and subkeys.
Provide Get-AllRegKey a list of computernames, and it wil... |
PowerShellCorpus/PoshCode/Remove-Games.ps1 | Remove-Games.ps1 | #/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\
#
# Script Name: Remove-Games.ps1
# Title: Remove Games
# Version: 1.0
# Author: John W. Cannon <johnwcannon at_gmail_dot_com>
# Date: September 20, 2011
#
# Description: This tool removes the built-in games... |
PowerShellCorpus/PoshCode/Download Free Reflector.ps1 | Download Free Reflector.ps1 | #Thanks http://27.am/posts/how-to-download-net-reflector-6-for-free
add-type @'
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
namespace LookingGlass
{
젨젨public class RedGateDownloader
젨젨젨젨public static void Download()
젨젨젨젨{
젨젨젨젨젨젨QueryDownloadUrl("... |
PowerShellCorpus/PoshCode/Dell Order Status.ps1 | Dell Order Status.ps1 | # Version: 0.1
# Author: Stefan Stranger
# Description: Retrieve Dell Order Status
# Start Page Order Status USA: https://support.dell.com/support/order/status.aspx?c=us&cs=19&l=en&s=dhs&~ck=pn
# Start Page Order Status EMEA(nl): http://support.euro.dell.com/support/index.aspx?c=nl&l=nl&s=gen&~ck=bt
# Example Dell... |
PowerShellCorpus/PoshCode/Deleted-ObjectsAD_1.ps1 | Deleted-ObjectsAD_1.ps1 | param(
$Domen,
$ObjectsDeleted
)
function Ping ($Name){
$ping = new-object System.Net.NetworkInformation.Ping
if ($ping.send($Name).Status -eq "Success") {$True}
else {$False}
trap {Write-Verbose "Error Ping"; $False; continue}
}
[string[]]$ObjectPath
[string[]]$Disks
[string[]]$Info
[st... |
PowerShellCorpus/PoshCode/disabled AD accounts_1.ps1 | disabled AD accounts_1.ps1 | #Get Domain List
$objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$DomainList = @($objForest.Domains | Select-Object Name)
$Domains = $DomainList | foreach {$_.Name}
#get users list
$users = Get-Content U:\\EMCU15FI3_USER.txt
$total = $users.count
"SAMaccountname;DisplayName... |
PowerShellCorpus/PoshCode/New-Type.ps1 | New-Type.ps1 | ## New-Type (like Add-Type, but for PowerShell 1.0)
## Takes C# source code, and compiles it (in memory) for use in scripts ...
####################################################################################################
## USAGE EXAMPLE:
## New-Type @"
## using System;
## public struct User {
#... |
PowerShellCorpus/PoshCode/Remove-Trash.ps1 | Remove-Trash.ps1 | #requires -version 2.0
add-type @"
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace recyclebin
{
public class Empty
{
[DllImport("shell32.dll")]
static extern int SHEmptyRecycleBin(IntPtr hWnd, string pszRootPath, uint dwFlags);
public... |
PowerShellCorpus/PoshCode/WPF v3 DEMO.ps1 | WPF v3 DEMO.ps1 | # Plik: 4_Demo_v3_Reflection.ps1
#requires -version 3
$Akceleratory =
[PSObject].
Assembly.
GetType("System.Management.Automation.TypeAccelerators")
Add-Type -AssemblyName PresentationCore, PresentationFramework -PassThru |
Where-Object IsPublic |
ForEach-Object {
$Class = $_
... |
PowerShellCorpus/PoshCode/Form manipulation.ps1 | Form manipulation.ps1 | $code = @'
using System;
using System.Runtime.InteropServices;
namespace LibWrap
{
public class Animator
{
[DllImport("user32.dll")]
public static extern bool AnimateWindow(IntPtr hWnd, uint dwTime, uint dwFlags);
}
}
'@
function BuildAssembly {
$cscp = New-Object Microsoft.CSharp.CShar... |
PowerShellCorpus/PoshCode/get-SQLInstanceInfo.ps1 | get-SQLInstanceInfo.ps1 | function get-SQLInstanceInfo
{
<#
.SYNOPSIS
get-SQLInstanceInfo
.DESCRIPTION
Retrieves the following information for each SQL Instance on the server or cluster node, and
returns as an array of PSCustomObjects
DisplayName
Name ... |
PowerShellCorpus/PoshCode/Replicate-ADDS.ps1 | Replicate-ADDS.ps1 | # Transcribe output to log
$null = Start-Transcript "$pwd\\$([System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Definition)).log"
# Check the QAD snapins are installed
if ( (Get-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction silentlycontinue) -eq $null ) {
# The QAD snapin is not act... |
PowerShellCorpus/PoshCode/Findup_28.ps1 | Findup_28.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/Convert-BounceToX_4.ps1 | Convert-BounceToX_4.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/ShowUI Clock 4.ps1 | ShowUI Clock 4.ps1 | New-UIWidget -AsJob -Content {
$shadow = DropShadowEffect -Color Black -Shadow 0 -Blur 8
Grid {
Ellipse -Fill Transparent -Stroke Black -StrokeThickness 4 -Width 300 -Height 300
Ellipse -Fill Transparent -Stroke Black -StrokeThickness 6 -Width 290 -Height 290 -StrokeDashArray 1,11.406
... |
PowerShellCorpus/PoshCode/Get-StatType proxy.ps1 | Get-StatType proxy.ps1 | # get-mystattype.ps1 : Proxy cmdlet for the Get-StatType cmdlet.
# The scripts add the parameter -ShowInstances to the cmdlet
# Parameters:
# ShowInstances : switch to define if all the instances for each metric will be shown
# Author: LucD
# History:
# v1.0 27/08/09 first version
#
[CmdletBinding()]
param(
... |
PowerShellCorpus/PoshCode/Lot buttons at one time.ps1 | Lot buttons at one time.ps1 | $frmMain_Load= {
for ($i = 0; $i -lt 2; $i++) {
for ($j = 0; $j -lt 5; $j++) {
$num[$i, $j] = $i * 5 + $j + 1
$btn[$i, $j] = New-Object Windows.Forms.Button
#
#btnX
#
$btn[$i, $j].Font = New-Object Drawing.Font("Tahoma", 14, [Drawing.FontStyle]::Bold)
$btn[$i, $j... |
PowerShellCorpus/PoshCode/Deploy VM with Static IP_1.ps1 | Deploy VM with Static IP_1.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:
$custSpec ... |
PowerShellCorpus/PoshCode/MacroScopeParser.ps1 | MacroScopeParser.ps1 | #requires -version 2
#Chad Miller
#http://www.sev17.com/
#Uses MacroScope/Antlr to parse SQL query for tables and table aliases
#Download MacroScope from http://macroscope.sourceforge.net/ and compile from source
#Or grab compiled assemblies from http://cid-ea42395138308430.skydrive.live.com/embedicon.aspx/Publi... |
PowerShellCorpus/PoshCode/repr_1.ps1 | repr_1.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/Get-Scope_4.ps1 | Get-Scope_4.ps1 | #function Get-Scope {
#.Synopsis
# Determine the scope of execution (are you in a module? how many scope layers deep are you?)
#.Parameter Invocation
# In order to correctly determine the scope, this function requires that you pass in the $MyInvocation variable when you call it.
#.Parameter ToHost
# If you ju... |
PowerShellCorpus/PoshCode/Start-AppVTestMode.ps1 | Start-AppVTestMode.ps1 | #This script is designed to set a test server to use a specific directory for App-V Apps, to enable testing
#Without having to publish to an external repository.
#REQUIREMENTS: Windows 2008
##FUNCTIONS
# DESCRIPTION: Displays the attention message box & checks to see if the user clicks the ok button.
function Sh... |
PowerShellCorpus/PoshCode/LibraryChart_2.ps1 | LibraryChart_2.ps1 | # ---------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller
### </Author>
### <Description>
### Defines functions for wokring with Microsoft Chart Control for .NET 3.5 Framework
### Pipe output of Powershell command to Out-Chart function and specify c... |
PowerShellCorpus/PoshCode/Enable-RemoteCredSSP.ps1 | Enable-RemoteCredSSP.ps1 | ##############################################################################\n##\n## Enable-RemoteCredSSP\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\nEna... |
PowerShellCorpus/PoshCode/BufferBox 3.5.ps1 | BufferBox 3.5.ps1 | ####################################################################################################
## This script is just a demonstration of some of the things you can do with the buffer
## in the default PowerShell host... it serves as a reminder of how much work remains on
## PoshConsole, and as an inspiration t... |
PowerShellCorpus/PoshCode/Dell Order Status_1.ps1 | Dell Order Status_1.ps1 | # Version: 0.1
# Author: Stefan Stranger
# Description: Retrieve Dell Order Status
# Start Page Order Status USA: https://support.dell.com/support/order/status.aspx?c=us&cs=19&l=en&s=dhs&~ck=pn
# Start Page Order Status EMEA(nl): http://support.euro.dell.com/support/index.aspx?c=nl&l=nl&s=gen&~ck=bt
# Example Dell... |
PowerShellCorpus/PoshCode/ESXiMgmt module sample 4.ps1 | ESXiMgmt module sample 4.ps1 | #######################################################################################################################
# File: ESXiMgmt_search_for_guest_hostname_sample.ps1 #
# Author: Alexander Petrovskiy ... |
PowerShellCorpus/PoshCode/ConvertTo-CliXml_2.ps1 | ConvertTo-CliXml_2.ps1 | #requires -version 2.0
function ConvertTo-CliXml {
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[PSObject[]]$InputObject
)
begin {
$type = [type]::gettype("System.Management.Automation.Serializer")
$ctor ... |
PowerShellCorpus/PoshCode/Event Log SOX audit.ps1 | Event Log SOX audit.ps1 | $s = "Server01", "Server02", "Server03"
foreach($server in $s) {$server
#$computername = Get-Content env:computername
$filter_Security = '<QueryList> <Query Id="0" Path="Security">
<Select Path="Security">(*[System[Provider[@Name="Microsoft-Windows-Security-Auditing"] and
(Task = 13824 or Task = 13825 or Ta... |
PowerShellCorpus/PoshCode/NFSMountUsingReference.ps1 | NFSMountUsingReference.ps1 |
################################################################################################################
# VMWare Standard Scripts - PowerCLI
#
# Purpose: Mount NFS datastore on new host server using reference host datstore
# Author: David Chung
# Docs: NA
# Date: 2/4/2012
#
#
# Instruction:... |
PowerShellCorpus/PoshCode/Get-ChildItemProxy.ps1 | Get-ChildItemProxy.ps1 | Function Get-ChildItemProxy {
[CmdletBinding(DefaultParameterSetName='Items', SupportsTransactions=$true)]
param(
[Parameter(ParameterSetName='Items', Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[System.String[]]
${Path},
[Parameter(ParameterSetName='LiteralItems... |
PowerShellCorpus/PoshCode/Backup Rotation (7zip).ps1 | Backup Rotation (7zip).ps1 | First file RotateBackups_MasterList.txt
RowNbr,BackupName,VersionsRetained,BackupType
1,TargetBackup,2,Folder
2,LstDefBackup,5,File
3,XMLBackup,3,File
4,SourceBackup,2,Folder
5,TXTBackup,8,File
Second file RotateBackups_FolderList.txt
RowNbr,BackupName,FolderName
1,TargetBackup,c:\\MyBooks\\target
2,SourceB... |
PowerShellCorpus/PoshCode/View-Process.ps1 | View-Process.ps1 | function View-Process {
param(
[string[]]$ComputerNames,
[string[]]$ProcessNames,
$User
)
###########################################################################################################
if ($User -is [String]) {
$Connection = Get-Credential -Credential $User
}
###################################... |
PowerShellCorpus/PoshCode/New-XVM_10.ps1 | New-XVM_10.ps1 | Function New-XVM
{
[cmdletbinding()]
Param
(
[Parameter(Mandatory=$false,Position=1)]
[string]$ComputerName=$env:COMPUTERNAME,
[Parameter(Mandatory=$true,Position=2)]
[string]$Name,
[Parameter(Mandatory=$true,Position=3)]
[string]$SwitchName,... |
PowerShellCorpus/PoshCode/Reflection_1.ps1 | Reflection_1.ps1 | $nul = "<NULL>"
function Get-AssembliesTree {
[AppDomain]::CurrentDomain.GetAssemblies() | % {
$nod = New-Object Windows.Forms.TreeNode
$nod.Text = $_.GetName().Name
$nod.Tag = $_
$tvAssem.Nodes.Add($nod)
$nod.Nodes.Add($nul)
}
}
function Add-Types {
$_.Node.Nodes.Clear()
... |
PowerShellCorpus/PoshCode/Spread-Mailboxes.ps1 | Spread-Mailboxes.ps1 | ###########################################################################
#
# NAME: Spread-Mailboxes.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jer@powershell.no
#
# COMMENT: Script to spread mailboxes alphabetically across mailboxdatabases based on the first character in the user`s displayname.
# For mo... |
PowerShellCorpus/PoshCode/Dir for days_2.ps1 | Dir for days_2.ps1 | Function Create-DatePaths {
Param (
[Parameter(Position=0,Mandatory=$True)]
[DateTime] $Start,
[Parameter(Position=1,Mandatory=$True)]
[ValidateScript({$_ -gt $Start})]
[DateTime] $End,
$DestinationPath=(Join-Path $env:UserProfile "Test")
)
0..(New-... |
PowerShellCorpus/PoshCode/Get-LocalGroups_1.ps1 | Get-LocalGroups_1.ps1 | function Add-NoteProperty {
<#
.Synopsis
Adds a NoteProperty member to an object.
.Description
This function makes adding a property a lot easier than Add-Member, assuming
you want to add a NoteProperty, which I find is true about 90% of the time.
.Parameter object
The object to add the property to.
... |
PowerShellCorpus/PoshCode/Harley.ps1 | Harley.ps1 | ###
# Description: Add Voice to Powershell
# Version: 1.1 (11 Nov 2008)
# Mike Hays / www.mike-hays.net / blog.mike-hays.net
# Virtualization, Powershell, and more...
###
# This is the actual speaking part. I cheat by adding spaces
# (This makes the word sound right).
$spokenText = "Super ca li fragilistic e... |
PowerShellCorpus/PoshCode/783e4a84-4d47-4c57-a257-2298ce2b32ff.ps1 | 783e4a84-4d47-4c57-a257-2298ce2b32ff.ps1 | Function Get-DiskUsage {
<#
.SYNOPSIS
A tribute to the excellent Unix command DU.
.DESCRIPTION
This command will output the full path and the size of any object
and it's subobjects. Using just the Get-DiskUsage command without
any parameters will result in an output of the directory you are
currently p... |
PowerShellCorpus/PoshCode/List DHCP Clients .ps1 | List DHCP Clients .ps1 | $DHCP_EnumSubnetClients = @'
[DllImport("dhcpsapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint DhcpEnumSubnetClients(
string ServerIpAddress,
uint SubnetAddress,
ref uint ResumeHandle,
uint PreferredMaximum,
out IntPtr ClientInfo,
ref uint E... |
PowerShellCorpus/PoshCode/count-object.ps1 | count-object.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 ($InputObject)
{
if ($inputobject -eq $Null ) { return 0}
if ($inputobject -is [system.array]) { return $inputobject.le... |
PowerShellCorpus/PoshCode/Start-ComputerJobs.ps1 | Start-ComputerJobs.ps1 | #requires -version 2.0
function Start-ComputerJobs{
<#
.NOTES
Name: Start-ComputerJobs
Author: Tome Tanasovski
Created: 6/25/2010
Version: 1.0
Website: http://powertoe.wordpress.com
.SYNOPSIS
Multithreads a scriptblock with jobs
.DESCRIPTION
The St... |
PowerShellCorpus/PoshCode/Is-Natural.ps1 | Is-Natural.ps1 | function is-natural{
param ($number)
if($number -like "*.*" -or $number -like "*-*"){
return $false
}else{return $true}
}
|
PowerShellCorpus/PoshCode/UIAutomation _1.6.ps1 | UIAutomation _1.6.ps1 | ## UI Automation v 1.7 -- REQUIRES the Reflection module (current version: http://poshcode.org/2480 )
##
# WASP 2.0 is getting closer, but this is still just a preview:
# -- a lot of the commands have weird names still because they're being generated ignorantly
# -- eg: Invoke-Toggle.Toggle and Invoke-Invoke.Invo... |
PowerShellCorpus/PoshCode/Lab Manager Demo.ps1 | Lab Manager Demo.ps1 | # Demo showing how to connect to VMware Lab Manager.
# Download LabManager.ps1 from http://www.poshcode.org/753.
. .\\LabManager.ps1
# Run this command if your Lab Manager's certificate is untrusted but you
# want to connect.
Ignore-SslErrors
# Connect to Lab Manager.
$labManager = Connect-LabManager -server... |
PowerShellCorpus/PoshCode/Invoke-RemoteCommand_2.ps1 | Invoke-RemoteCommand_2.ps1 | <#
# Script FileName: func_Invoke-RemoteCommand.ps1
# Current Version: A03
# Description: Run command on a remote computer as the currently logged on user.
# Created By: Adam Listek
# Version Notes
# A01 - Initial Release
# A02 - Conversion to Function
# A03 - Abstracted to generic purpos... |
PowerShellCorpus/PoshCode/Generate Random Data.ps1 | Generate Random Data.ps1 | $dictionaryWords = gc $dictionaryFile
$azLower = 'abcdefghijklmnopqrstuvwxyz'.ToCharArray()
$azUpper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.ToCharArray()
$hex = '012345679ABCDEF'.ToCharArray()
$digit = '0123456789'.ToCharArray()
$alphanumeric = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.ToCharArray()... |
PowerShellCorpus/PoshCode/Select-ToString_2.ps1 | Select-ToString_2.ps1 | [CmdletBinding(DefaultParameterSetName='DefaultParameter')]
param(
[Parameter(ValueFromPipeline=$true)]
[System.Management.Automation.PSObject]
${InputObject},
[Parameter(ParameterSetName='DefaultParameter', Position=0, Mandatory=$true)]
[System.String[]]
${Property},
[Parameter(... |
PowerShellCorpus/PoshCode/Convert-BounceToX_9.ps1 | Convert-BounceToX_9.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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.