full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PoshCode/Find sharable storage.ps1
Find sharable storage.ps1
# This function returns all datastores that can be shared amongst ESX hosts. function Get-ShareableDatastore { # Get all datastores. $datastores = Get-Datastore # Load the HostStorageSystems of all hosts. $hosts = Get-VMHost | Get-View -property ConfigManager $storageSystems = @() foreach ($h in $hosts) ...
PowerShellCorpus/PoshCode/OnTapSDK_Discoverability.ps1
OnTapSDK_Discoverability.ps1
# Glenn Sizemore www . Get-Admin . com # Requires the NetApp OnTap SDK v3.5 # Get-NaAPI # Will return a list of ZAPI Calls that the filer supports. Can be used # as a poor man's Get-Command for the OnTap SDK. ######################################################################### # Usage: # Connect to the f...
PowerShellCorpus/PoshCode/Import-Methods_1.ps1
Import-Methods_1.ps1
# [CmdletBinding()] param( #[Parameter(Position=1,ValueFromPipeline=$true)] [type]$type , #[Parameter()] #[Alias("Properties")] [switch]$IncludeProperties ) BEGIN { function MakeFunction() { PROCESS { $func = "function:global:$($_.name)" if (test-path $func) { remove-item ...
PowerShellCorpus/PoshCode/PowerShell_ISE Profile_1.ps1
PowerShell_ISE Profile_1.ps1
#-------------------------------------------------------------------------------------------------------------- #Convert Untitled1.ps1 to ASCII encoding $psise.CurrentPowerShellTab.Files | % { # set private field which holds default encoding to ASCII $_.gettype().getfield("encoding","nonpublic,instance")....
PowerShellCorpus/PoshCode/COE_IMAGE.ps1
COE_IMAGE.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/Execute in PowerShell.ps1
Execute in PowerShell.ps1
#=================================================================================== # # Filename: AddExecuteInPowerShellToPS1Files.ps1 # # Author: Nigel Boulton # # Version: 1.00 # # Date: 9 Nov 2008 # # Mod dates: # # Purpose: To add context menu items for .ps1 files in Windows Explorer, to # allow...
PowerShellCorpus/PoshCode/AutoArchive.ps1
AutoArchive.ps1
# AutoArchive PowerShell Script # http://powershell.codeplex.com param ( [ValidateNotNullOrEmpty()] [Parameter( Mandatory = $true) ] [string] $Source, [int] $RetentionDays, [array] $Include, [array] $Exclude, [switch] $Recurse ) # Load Zip Module Import-Module PowerZip # Che...
PowerShellCorpus/PoshCode/Demo-ShouldProcess.ps1
Demo-ShouldProcess.ps1
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="Medium")] param([Switch]$Force) $RejectAll = $false; $ConfirmAll = $false; foreach($file in ls) { if($PSCmdlet.ShouldProcess( "Removed the file '$($file.Name)'", "Remove the file '$($file.Name)'?", ...
PowerShellCorpus/PoshCode/ISE-CopyOutPutToEditor_2.ps1
ISE-CopyOutPutToEditor_2.ps1
function ISE-CopyOutPutToEditor () { $count = $psise.CurrentPowerShellTab.Files.count $psIse.CurrentPowerShellTab.Files.Add() $Newfile = $psIse.CurrentPowerShellTab.Files[$count] $Newfile.Editor.Text = $psIse.CurrentPowerShellTab.Output.Text $Newfile.Editor.Focus() } $null = $psISE.CurrentPow...
PowerShellCorpus/PoshCode/Desktop.ps1
Desktop.ps1
#region License // Desktop 1.1 // * // Copyright (C) 2004 http://www.onyeyiri.co.uk // Coded by: Nnamdi Onyeyiri // // This code may be used in any way you desire except for commercial use. // The code can be freely redistributed unmodified as long as all of the authors //...
PowerShellCorpus/PoshCode/get-ESXiHostConfigBackup_1.ps1
get-ESXiHostConfigBackup_1.ps1
<# .SYNOPSIS Creates config bundle backup for ESXi hosts. Works where 80 is blocked to ESXi host Originally script by Alan Renouf (http://www.virtu-al.net/2011/02/23/backing-up-the-esxi-system-image) Heavily Modified by Jimmy Hester .DESCRIPTION Checks for connection to a vCenter or ESXi server If not connected...
PowerShellCorpus/PoshCode/Set-OutlookSignature_2.ps1
Set-OutlookSignature_2.ps1
###########################################################################¡± # # NAME: Set-OutlookSignature.ps1 # # AUTHOR: Jan Egil Ring # Modifications by Darren Kattan # # COMMENT: Script to create an Outlook signature based on user information from Active Directory. # Adjust the variables in the ¡°Custom v...
PowerShellCorpus/PoshCode/Start-Verify.ps1
Start-Verify.ps1
# Author: Steven Murawski http://www.mindofroot.com # This script creates two functions (and a helper function). One starts logging all commands entered, # and the second removes the logging. # This script is similar to the Start-Transcript, but only logs the command line and not the output. function New-Scr...
PowerShellCorpus/PoshCode/Get-ADGroupMembers_4.ps1
Get-ADGroupMembers_4.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/LibraryDirectory.ps1
LibraryDirectory.ps1
## From Windows PowerShell Cookbook (O'Reilly)\n## by Lee Holmes (http://www.leeholmes.com/guide)\n\nSet-StrictMode -Version Latest\n\n## Get the size of all the items in the current directory\nfunction Get-DirectorySize\n{\n <#\n\n .EXAMPLE\n\n PS > $DebugPreference = "Continue"\n PS > Get-DirectorySize\n ...
PowerShellCorpus/PoshCode/Import Group Policies.ps1
Import Group Policies.ps1
############################################## ##Import group policies from a folder to a Domain Controller ##Author: Adam Liquorish ## ##*Currently will only run on Server 2008 R2 ##*Script is based on the Microsoft Visual Basic Script for importing group policies. ##*Server doesnt need to be defined as PDC emul...
PowerShellCorpus/PoshCode/finddupe_18.ps1
finddupe_18.ps1
# new version has more error handling, "-delete" and "-noprompt" options. function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) { $stream = $null; $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider]; $hashAlgorithm = new-object $cryp...
PowerShellCorpus/PoshCode/WhoIs_1.ps1
WhoIs_1.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/Enable_Configure SNMP.ps1
Enable_Configure SNMP.ps1
#Powershell Script To Install SNMP Services (SNMP Service, SNMP WMI Provider) #Variables :) $pmanagers = "ADD YOUR MANAGER(s)" $commstring = "ADD YOUR COMM STRING" #Import ServerManger Module Import-Module ServerManager #Check If SNMP Services Are Already Installed $check = Get-WindowsFeature | Where-Objec...
PowerShellCorpus/PoshCode/Out-Balloon_3.ps1
Out-Balloon_3.ps1
<# .Synopsis Makes a baloon tip in the notification area .Description With just a few arguments, it is easy to make some text appear in a little balloon. You can specify an icon file (*.ico) with the -icon argument, if you don't then the first icon of the host is used. out-balloo...
PowerShellCorpus/PoshCode/test connectivity.ps1
test connectivity.ps1
$ping = new-object System.Net.NetworkInformation.Ping $isbad = $true; do { try { $Reply = $ping.send('www.yahoo.com') if ($Reply.status –ne “Success”) { $txt = "$(get-date) problem" ; write-Host $txt ; $txt | out-File -append c:\\downloads\\jetstreamlog.txt} else { if ($isbad) {$isbad ...
PowerShellCorpus/PoshCode/LNK file testing_1.ps1
LNK file testing_1.ps1
param( $Path = (Split-Path $PSHOME -Qualifier) ) if($lnks -eq $null) { $lnks = ls $Path -Recurse -Filter "*.lnk" } $wsh = New-Object -ComObject WScript.Shell; foreach($lnk in $lnks) { $lnko = $wsh.CreateShortcut($lnk.fullname); $rtn = New-Object psobject -Property @{ "FilePath...
PowerShellCorpus/PoshCode/DefaultParameterValues_3.ps1
DefaultParameterValues_3.ps1
# DefaultParameters Module # 1.4 - removed extra parameter set to get parameter binding working better # - added default aliases (sdp/gdp/rmdp) #requires -version 3.0 # 1.3 - fixed denable/disable, added get and remove, and improved import and set # 1.2 - added help and commands to enable/disable the defaults ...
PowerShellCorpus/PoshCode/4bbeb588-aa6d-475c-861b-05a432703d58.ps1
4bbeb588-aa6d-475c-861b-05a432703d58.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/Join-Collections 2.0.ps1
Join-Collections 2.0.ps1
#requires -version 2.0 #################################################################################################### ## Version History: ## ## Version 2.0 Added Join-Object and removed dependency on ConvertFrom-Hashtable ## Now works on DataTables! ## Version 1.1 Fixed column uniqueness bug ...
PowerShellCorpus/PoshCode/LoadModuleConfig.ps1
LoadModuleConfig.ps1
################################################################################ ## Script Name: LoadModuleConfig ## Created On: 01/21/2010 ## Author: Thell Fowler ## File: LoadModuleConfig.ps1 ## Usage: Called from the NestedModules value from a module manifest. ## Version:...
PowerShellCorpus/PoshCode/Get # of Web Connections.ps1
Get # of Web Connections.ps1
function Get-WebServiceConnections() { $results = @{} $perfmon = new-object System.Diagnostics.PerformanceCounter $perfmon.CategoryName = "Web Service" $perfmon.CounterName = "Current Connections" $cat = new-object System.Diagnostics.PerformanceCounterCategory("Web Service") $instances = $cat.GetIn...
PowerShellCorpus/PoshCode/Enable_Configure SNMP_1.ps1
Enable_Configure SNMP_1.ps1
#Powershell Script To Install SNMP Services (SNMP Service, SNMP WMI Provider) #Variables :) $pmanagers = "ADD YOUR MANAGER(s)" $commstring = "ADD YOUR COMM STRING" #Import ServerManger Module Import-Module ServerManager #Check If SNMP Services Are Already Installed $check = Get-WindowsFeature | Where-Objec...
PowerShellCorpus/PoshCode/Security group monitor_3.ps1
Security group monitor_3.ps1
#Get group membership for a list of security #groups and export to an XML for comparison #against baseline. # $script:WorkingDirectory = split-path $myinvocation.Mycommand.Definition -parent Function Re-Baseline { #First, declare array and hashtable. $securitygroups = @() $table = @{} #Import Security...
PowerShellCorpus/PoshCode/ErrorLogstoHTML.ps1
ErrorLogstoHTML.ps1
$a="<style>" $a=$a+"BODY{background-color :#FFFFF}" $a=$a+"TABLE{Border-width:thin;border-style: solid;border-color:Black;border-collapse: collapse;}" $a=$a+"TH{border-width: 0px;padding: 0px;border-style: solid;border-color: black;background-color: ThreeDShadow}" $a=$a+"TD{border-width: 1px;padding: 0px;border-sty...
PowerShellCorpus/PoshCode/Find-GeoCode_1.ps1
Find-GeoCode_1.ps1
$mappoint = New-WebServiceProxy http://staging.mappoint.net/standard-30/mappoint.wsdl -Namespace MapPoint $FindService = new-object MapPoint.FindServiceSoap # You need an account, sign up here: https://mappoint-css.live.com/mwssignup $FindService.Credentials = Get-Credential function Find-ReverseGeoCode( [double...
PowerShellCorpus/PoshCode/Get KB-articles of SP_1.ps1
Get KB-articles of SP_1.ps1
function Get-Sp1Articles() { $web = New-Object System.Net.WebClient # Microsoft XLS-Datei über google herunterladen, damit kommt die XLS-Datei als in HTML konvertierte Datei $html = $web.DownloadString(‘http://webcache.googleusercontent.com/search?q=cache:trZowCK8jvcJ:download.microsoft.com/download/...
PowerShellCorpus/PoshCode/Get-ObservedIPRange.ps1
Get-ObservedIPRange.ps1
function Get-ObservedIPRange { param( [Parameter(Mandatory=$true,ValueFromPipeline=$true,HelpMessage="Physical NIC from Get-VMHostNetworkAdapter")] [VMware.VimAutomation.ViCore.Impl.V1.Host.Networking.Nic.PhysicalNicImpl] $Nic ) process { $hostView = Get-VMHost -Id $Nic.VMHostId | Get-View -Property...
PowerShellCorpus/PoshCode/Send-HTMLFormattedEmail.ps1
Send-HTMLFormattedEmail.ps1
#------------------------------------------------- # Send-HTMLFormattedEmail #------------------------------------------------- # Usage: Used to display help information. # **Parameters are not for interactive execution.** #------------------------------------------------- function Send-HTMLFormattedEmail{ p...
PowerShellCorpus/PoshCode/usr mailbox in exch 07.ps1
usr mailbox in exch 07.ps1
#Generamos los usuarios por buzon y comprimimos el resultado #Autor: Pedro Genil #Fecha: 2012/11/21 #Version: 1.0 # Aþadimos modulo If ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null) { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin } # Creamos el alias para el 7zip if (...
PowerShellCorpus/PoshCode/BinaryClock V_1.0.ps1
BinaryClock V_1.0.ps1
Function Start-BinaryClock { <# .SYNOPSIS This is a binary clock that lists the time in hours, minutes and seconds .DESCRIPTION This is a binary clock that lists the time in hours, minutes and seconds. Key Input Tips: r: Toggles the resize mode of the clock so you can adjust the size....
PowerShellCorpus/PoshCode/8796ba7c-730c-45aa-ac56-3b561a1149d2.ps1
8796ba7c-730c-45aa-ac56-3b561a1149d2.ps1
# Copyright (c) 2011 Code Owls LLC, All Rights Reserved. # # 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, mod...
PowerShellCorpus/PoshCode/Watch-Process_1.ps1
Watch-Process_1.ps1
Function Watch-Process { <# .DESCRIPTION Creates an event handler for monitoring either process creation or deletion. This requires to be run as administrator. .SYNOPSIS Watches for process creation or deletion. .PARAMETER computerName Name of the remote computer. Make sure you have privileges to acces...
PowerShellCorpus/PoshCode/Restart-IISAppPool_1.ps1
Restart-IISAppPool_1.ps1
function Restart-IISAppPool { [CmdletBinding(SupportsShouldProcess=$true)] #.Synopsis # Restarts an IIS AppPool #.Parameter ComputerName # The name of an IIS web server where the AppPool resides #.Parameter AppPool # The name of the AppPool to recycle (if you include wildcards, results in...
PowerShellCorpus/PoshCode/NPS Server Synchronize_2.ps1
NPS Server Synchronize_2.ps1
###Network Policy Server Synchronization Script #This script copies the configuration from the NPS Master Server and imports it on this server. #The Account that this script runs under must have Local Administrator rights to the NPS Master. #This was designed to be run as a scheduled task on the NPS Secondary Server...
PowerShellCorpus/PoshCode/Invoke-MoveRequest_2.ps1
Invoke-MoveRequest_2.ps1
########################################################################### # # NAME: Invoke-MoveRequest.ps1 # # AUTHOR: Jan Egil Ring # EMAIL: jer@powershell.no # # COMMENT: Script to use when migrating mailboxes to Microsoft Exchange Server 2010 Cross-Forest. Prepares user objects already # moved to...
PowerShellCorpus/PoshCode/Get-LocalGroupMembers.ps1
Get-LocalGroupMembers.ps1
function Get-LocalGroupMembers { param($groupname) $pattern = "*Name=`"$groupname`"" $groupusers = gwmi Win32_GroupUser | Where { $_.GroupComponent -like $pattern } # Now extract the usernames. foreach ($user in $groupusers) { if ($user.PartComponent -match 'Name="([^"]+)') { Write-Output $matches[...
PowerShellCorpus/PoshCode/Security group monitor.ps1
Security group monitor.ps1
#Get group membership for a list of security #groups and export to an XML for comparison #against baseline. # $script:WorkingDirectory = split-path $myinvocation.Mycommand.Definition -parent Function Re-Baseline { #First, declare array and hashtable. $securitygroups = @() $table = @{} #Import Security...
PowerShellCorpus/PoshCode/Get-PendingUpdates.ps1
Get-PendingUpdates.ps1
Function Get-PendingUpdates { <# .SYNOPSIS Retrieves the updates waiting to be installed from WSUS .DESCRIPTION Retrieves the updates waiting to be installed from WSUS .PARAMETER Computer Computer or computers to find updates for. .EXAMPLE Get-PendingUpdates ...
PowerShellCorpus/PoshCode/Get-Parameter_11.ps1
Get-Parameter_11.ps1
function Get-Parameter ( $Cmdlet, [switch]$ShowCommon, [switch]$Full ) { $command = Get-Command $Cmdlet -ea silentlycontinue # resolve aliases (an alias can point to another alias) while ($command.CommandType -eq "Alias") { $command = Get-Command ($command.definition) } if (-not $command) { return } ...
PowerShellCorpus/PoshCode/Compare-DatabaseColumns.ps1
Compare-DatabaseColumns.ps1
param( [String[]]$Table = $null, $SqlServerOne = 'YourDatabaseServer', $FirstDatabase = 'FirstDatabaseToCompare', $SqlUsernameOne = 'SQL Login', $SqlPasswordOne = 'SQL Password', $SqlServerTwo = 'YourDatabaseServer', $SecondDatabase = 'SecondDatabaseToCompare', ...
PowerShellCorpus/PoshCode/Get-Parameter 2.5.ps1
Get-Parameter 2.5.ps1
#Requires -version 2.0 #.Synopsis # Enumerates the parameters of one or more commands #.Notes # With many thanks to Hal Rottenberg, Oisin Grehan and Shay Levy # Version 0.80 - April 2008 - By Hal Rottenberg http://poshcode.org/186 # Version 0.81 - May 2008 - By Hal Rottenberg http://poshcode.org/255 # Ver...
PowerShellCorpus/PoshCode/Import-GalPhoto.ps1
Import-GalPhoto.ps1
<# .Synopsis Import Exchange 2010 Gal photo for one or more users. .DESCRIPTION This function invokes the Import-RecipientDataProperty cmdldet to import a picture into the thumbnailPhoto attribute of an Exchange mailbox. It assumes you have a directory containing all images to import, with the file names...
PowerShellCorpus/PoshCode/ShowUI Weather Widget_1.ps1
ShowUI Weather Widget_1.ps1
## And a slick weather widget using Yahoo's forecast and images New-UIWidget -AsJob { Grid { Rectangle -RadiusX 10 -RadiusY 10 -StrokeThickness 0 -Width 170 -Height 80 -HorizontalAlignment Left -VerticalAlignment Top -Margin "60,40,0,0" -Fill { LinearGradientBrush -Start "0.5,0" -End "0.5,...
PowerShellCorpus/PoshCode/Migrate UserFolder.ps1
Migrate UserFolder.ps1
param( $RootFolder = "\\\\domain.local\\users", $NewRootFolder = "\\\\domain.local\\users2", $LogFolder = "c:\\Projects\\HomeDirs", $NewSubFolders = @("Documents","Favorites","Desktop","Links","Contacts","BlaBla"), [switch]$SetACL ) $UserFolders = gci -Path $RootFolder | ?{$_.PSIsContainer} $UserFolders | forea...
PowerShellCorpus/PoshCode/Speech Recognition_1.ps1
Speech Recognition_1.ps1
$null = [Reflection.Assembly]::LoadWithPartialName("System.Speech") ## Create the two main objects we need for speech recognition and synthesis if(!$Global:SpeechModuleListener){ ## For XP's sake, don't create them twice... $Global:SpeechModuleSpeaker = new-object System.Speech.Synthesis.SpeechSynthesizer ...
PowerShellCorpus/PoshCode/84835da8-9f4e-46f7-84f6-64197c8d0f7b.ps1
84835da8-9f4e-46f7-84f6-64197c8d0f7b.ps1
Hi, I've tried your excellent -Append feature for export-csv and it works good. I've only have a short question. Is it possible to make the append to new columns instead of rows? I'd like to combine two csv files as a part of an automation script and then I must get this to work. Import-csv C:\\Visiolizer\...
PowerShellCorpus/PoshCode/Get-User_8.ps1
Get-User_8.ps1
$script:dse = 'LDAP://my.domain.com' function script:User-Exists([string]$username) { $username = $($username).Trim() $srch = New-Object DirectoryServices.DirectorySearcher $global:dse $srch.Filter = "(&(objectClass=user)(sAMAccountName=$username))" $srch.PageSize = 10000 $srch.SearchScope = "Subtree...
PowerShellCorpus/PoshCode/Test-64BitOS.ps1
Test-64BitOS.ps1
Add-Type -TypeDefinition @" using System; using System.Runtime.InteropServices; public static class Win32Api { [DllImport("Kernel32.dll", EntryPoint = "IsWow64Process")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsWow64Process( [In] IntPtr hProcess, [Out, M...
PowerShellCorpus/PoshCode/AD-GroupMembers_v1.ps1
AD-GroupMembers_v1.ps1
function AD-GroupMembers() { param ( $Domen, $Group, $User ) if ($User){$Connection = Get-Credential -Credential $user} if($Connection){$Member = Get-QADGroupMember -Service $Domen -Identity $Group -Credential $Connection -SizeLimit 0 -ErrorAction SilentlyContinue | Sort Name | Format-Table Name,NTAccountName,Si...
PowerShellCorpus/PoshCode/PowerSmug - Sync Smugmug.ps1
PowerSmug - Sync Smugmug.ps1
# PowerSmug photo sync script v1.0 # This PowerShell script will syncronize a folder of images with a users SmugMug account # Please set the appropriate variables in the User Defined Variables region # For more information visit # # Images are uploaded to a gallery with the same name as the folder they are contai...
PowerShellCorpus/PoshCode/Parse HTML Tables.ps1
Parse HTML Tables.ps1
# Parse tables within HTML files and return the rows as PowerShell objects. # The idea here is similar to (though not nearly as complete as) Perl's HTML::TableParse. # This function should run anywhere but it's a bit slow because of the COM interface # it uses. There seem to be a few .NET libraries out there that wo...
PowerShellCorpus/PoshCode/Get-EwsEmail.ps1
Get-EwsEmail.ps1
$ewsPath = "C:\\Program Files\\Microsoft\\Exchange\\Web Services\\1.1\\Microsoft.Exchange.WebServices.dll" Add-Type -Path $ewsPath $ews = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService -ArgumentList "Exchange2007_SP1" $cred = (Get-Credential).GetNetworkCredential() $ews.Credentials = New-Object Sy...
PowerShellCorpus/PoshCode/Get-GroupMembership_3.ps1
Get-GroupMembership_3.ps1
## Get-DistinguishedName -- look up a DN from a user's (login) name function Get-DistinguishedName { Param($UserName) $ads = New-Object System.DirectoryServices.DirectorySearcher([ADSI]'') $ads.filter = "(&(objectClass=Person)(samAccountName=$UserName))" $s = $ads.FindOne() return $s.GetDirectoryEnt...
PowerShellCorpus/PoshCode/Get-EnumValues.ps1
Get-EnumValues.ps1
function Get-EnumValues ( $EnumType ) { # Code somewhat stolen from Joel here: http://huddledmasses.org/ideas-for-writing-composable-powershell-scripts/ Begin { $listItems = @() } Process { if( $_ -is [type] -and $_.IsEnum ) { $listItems+= [Enum]::GetValues($_) } elseif( $_.GetType().IsEnum ) { ...
PowerShellCorpus/PoshCode/test_1.ps1
test_1.ps1
[CmdletBinding()] param() "This file is in the $PSScriptRoot folder." # SIG # Begin signature block # MIIPGwYJKoZIhvcNAQcCoIIPDDCCDwgCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUtq5NTq7Q77yPgrtRePzRWHVn # THuggg...
PowerShellCorpus/PoshCode/new.ps1
new.ps1
$Shell = New-Object -com shell.application $NetCons = $Shell.Namespace(0x31) $NetCons.Items() | where {$_.Name -like 'Local Area Connection*'} | foreach{$AdapName=$_.Name; get-WmiObject -class Win32_NetworkAdapter | where-Object {$_.NetConnectionID -eq $AdapName} | foreach {$MAC=$_.MacAddress} ...
PowerShellCorpus/PoshCode/Prevent-Screensaver_1.ps1
Prevent-Screensaver_1.ps1
######################################################### # Prevent-Screensaver ######################################################### # This script "presses" a keyboard key every minute # for specified number of minutes which makes # Windows "think" you are at your desktop # so the screensaver does not start ...
PowerShellCorpus/PoshCode/Get-Packet.ps1
Get-Packet.ps1
# # get-packet.ps1 # # Receives and displays all incoming IP packets. NIC driver must support promiscuous mode. # # Usage: get-packet.ps1 [-LocalIP [<String>]] [-Protocol [<String>]] [[-Seconds] [<Int32>]] [-ResolveHosts] [-Statistics] [-Silent] # # Author: Robbie Foust (rfoust@duke.edu) # Date: Nov 19, 2007 ...
PowerShellCorpus/PoshCode/Download-FreeReflector.p.ps1
Download-FreeReflector.p.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/Balance-Datastores.ps1
Balance-Datastores.ps1
#Parameter- Name of the VMware cluster to work in param($cluster) Write-Output "`n$(Get-Date)- Script started`n" # Validate parameter input $IsClusterNameInvalid = $true Get-Cluster | % { If ($_.Name -eq $Cluster) {$IsClusterNameInvalid = $false} } If ($IsClusterNameInvalid) { Write-Host "Error- Invalid Clu...
PowerShellCorpus/PoshCode/Check Service_1.ps1
Check Service_1.ps1
#################################################################################### #PoSH script to check if a server is up and if it is check for a service. #If the service isn't running, start it and send an email # JK - 7/2009 #Updated: 07/22/09 by Steven Murawski (http://blog.usepowershell.com) #Changed the p...
PowerShellCorpus/PoshCode/GUI ProductKey.ps1
GUI ProductKey.ps1
$def = (gci $MyInvocation.MyCommand.Name).Directory ################################################################################################## $mnuScan_Click= { $lstView.Items.Clear() try { Get-AllData ("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion") Get-AllData (Expand-OfficeKey) } ...
PowerShellCorpus/PoshCode/Enable and Configure SNM.ps1
Enable and Configure SNM.ps1
#Powershell Script To Install SNMP Services (SNMP Service, SNMP WMI Provider) #Variables :) $pmanagers = "ADD YOUR MANAGER(s)" $commstring = "ADD YOUR COMM STRING" #Import ServerManger Module Import-Module ServerManager #Check If SNMP Services Are Already Installed $check = Get-WindowsFeature | Where-Objec...
PowerShellCorpus/PoshCode/getMyModulePrefix.ps1
getMyModulePrefix.ps1
function getMyModulePrefix { <# .SYNOPSIS An internal support routine for imported modules to retrieve a prefix assigned using the Import-Module -prefix argument. .DESCRIPTION Functions in modules imported with the -prefix option have two command names. The module defined name and the prefixed name. ...
PowerShellCorpus/PoshCode/FS_FindFiles_1.ps1
FS_FindFiles_1.ps1
Param ( [string[]]$Computers=$env:ComputerName, [string[]] $Paths = @("C:\\Windows","C:\\Windows\\system32"), [string[]] $FileNames = @("fsb.tmp","fsb.stb","notpad.exe") ) $Global:objOut = @() Function FindFiles ($Computer, $Filter){ try{ $Files = Gwmi -namespace "root\\CIMV2" -computername $Computer...
PowerShellCorpus/PoshCode/Update-vSwitchSecurity.ps1
Update-vSwitchSecurity.ps1
#requires -version 2.0 # Author: Glenn Sizemore 12/19/2009 # Source: http://get-admin.com/blog/?p=239 # # v1.0 : It works Cmdlet Update-vSwitchSecurity -SupportsShouldProcess { param ( [Parameter(position=0,Mandatory=$TRUE,HelpMessage="Name of the vSwitch to modify")] [string] $vSwitch, [Parameter(po...
PowerShellCorpus/PoshCode/Audit NTFS on Shares.ps1
Audit NTFS on Shares.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/Product key_5.ps1
Product key_5.ps1
from System import Array, Char, Console from System.Collections import ArrayList from Microsoft.Win32 import Registry def DecodeProductKey(digitalProductID): map = ("BCDFGHJKMPQRTVWXY2346789").ToCharArray() key = Array.CreateInstance(Char, 29) raw = ArrayList() i = 52 while i < 67: raw...
PowerShellCorpus/PoshCode/TheGameOfLife.ps1
TheGameOfLife.ps1
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null $SCRIPT:hostProperties = @{}; $SCRIPT:hostState = $null; $SCRIPT:BoardWidth = 50; $SCRIPT:BoardHeight = 50; Function Initialize-Host { Param( [Parameter(Mandatory=$false)] $wndTitle = "Game of Life...", [Parameter(Ma...
PowerShellCorpus/PoshCode/Advanced search.ps1
Advanced search.ps1
<# Using examples: Example 1: Get-ItemPlace *.log -h It will search all (including that have "Hidden" attribute) *.log files on local drives. Example 2: Get-ItemPlace sysinternals hkcu:\\ This command invoke search Sysinyetrnals key into HKEY_CURRENT_USER. #> function Get-ItemPlace { param ([s...
PowerShellCorpus/PoshCode/Import-ExcelToSQL_2.ps1
Import-ExcelToSQL_2.ps1
#Change these settings as needed $filepath = 'C:\\Users\\u00\\Documents\\backupset.xlsx' #Comment/Uncomment connection string based on version #Connection String for Excel 2007: $connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=`"$filepath`";Extended Properties=`"Excel 12.0 Xml;HDR=YES`";" #Connection S...
PowerShellCorpus/PoshCode/SharePoint Large Lists_1.ps1
SharePoint Large Lists_1.ps1
[reflection.assembly]::loadwithpartialname("Microsoft.SharePoint") $cs = [microsoft.sharepoint.administration.spwebservice]::ContentService $global:largeListThreshhold = 2000 function Is-Admin([Microsoft.SharePoint.SPRoleAssignment]$roleAssignment) { return (($roleAssignment.roledefinitionbindings | where { ($_...
PowerShellCorpus/PoshCode/Pipeline and Parameter_1.ps1
Pipeline and Parameter_1.ps1
param( [Parameter(ValueFromPipeline=$true, Mandatory=$true, Position=0)] [string[]] $ComputerName ) Process { foreach ($cn in $ComputerName) { Write-Host "Processing $cn" } }
PowerShellCorpus/PoshCode/Get-DNSZoneRecords_1.ps1
Get-DNSZoneRecords_1.ps1
#========================================================================== # NAME: Get-DNSZoneRecords.ps1 # AUTHOR: Saehrig, Steven (trac3r726) # DATE : 10/17/2008 # # COMMENT: # Just comment out the variable and enter the info you need for # computername, dnszonename, and remove the credential portion if no...
PowerShellCorpus/PoshCode/330802b9-dd0b-41e6-8020-cd304a79d948.ps1
330802b9-dd0b-41e6-8020-cd304a79d948.ps1
function Run-Query($siteUrl, $queryText) { [reflection.assembly]::loadwithpartialname("microsoft.sharePOint") | out-null [reflection.assembly]::loadwithpartialname("microsoft.office.server") | out-null [reflection.assembly]::loadwithpartialname("microsoft.office.server.search") | out-null $s = [microsoft.share...
PowerShellCorpus/PoshCode/Audit iPhone_Palm Users_1.ps1
Audit iPhone_Palm Users_1.ps1
#Created by P. Sukus #Modified by D. Dill #Name: mobile users syncing through OWA audit #set the timeframe to audit in days $Daysold = 1 $Date = (get-date).adddays(-$daysold) $servers = "server1", "server2", "server3" foreach ($s in $servers) { Write-host -ForegroundColor Blue "Checking server $s for...
PowerShellCorpus/PoshCode/chkhash_29.ps1
chkhash_29.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/PS FindFirstFileW.ps1
PS FindFirstFileW.ps1
param( [string] $dirRoot = $pwd, [string] $Spec = "*.*", [bool] $longOnly = $false ) # Changes: # 23/05/2008, Wayne Martin, Added the option to only report +max_path entries, and report the short path of those directories (which makes it easier to access them) # # # Description: # Use the wide...
PowerShellCorpus/PoshCode/44121121-b64f-42c2-b48d-d6b74bc5fbb6.ps1
44121121-b64f-42c2-b48d-d6b74bc5fbb6.ps1
####################### <# .SYNOPSIS Execute T-SQL Statments and return messages from SQL Server (print). .DESCRIPTION Execute T-SQL Statments and return messages from SQL Server (print). .INPUTS None You cannot pipe objects to Invoke-ExecuteTSQL .OUTPUTS PSObject : Boolean Exitcode = $True or $False in...
PowerShellCorpus/PoshCode/Server checks.ps1
Server checks.ps1
##Creates variable for filename $date = (get-date).tostring("yyyy-MM-dd") $filename = "H:\\dailychecks\\checks_$date.xls" ## Imports exchange modules Import-Module "\\\\emailserver\\c$\\PS Modules\\vamail.videoarts.info.psm1" ## Start Internet Explorer to check that Video Arts website is up Start-Proces...
PowerShellCorpus/PoshCode/Set-FSMORoleOwner.ps1
Set-FSMORoleOwner.ps1
Function Set-FSMORoleOwner { <# .SYNOPSIS Performs a transfer of a FSMO role to a specified Domain Controller. .DESCRIPTION Performs a transfer of a FSMO role to a specified Domain Controller. .PARAMETER DomainController Fully Qualified Domain Name of the Domain Controller to take a tr...
PowerShellCorpus/PoshCode/pscp & spaces.ps1
pscp & spaces.ps1
Script set-psdebug -trace 2 $sftp = "c:\\bin\\pscp.exe" $sftpusername = "username" $sftppassword = "password" $sftphost = "sftp.host.com" $sftpdestination = "`"`/Test Test`/`"" [Array]$sftpArgs = "-sftp", "-v", "-l", "$sftpusername", "-pw", "$sftppassword", "c:\\calinstall.log", "$sftphost`:$sftpdestination"; ...
PowerShellCorpus/PoshCode/Join-Objects 2.1.ps1
Join-Objects 2.1.ps1
#function Join-Object { Param( [Parameter(Position=0)] $First , [Parameter(Position=1)] $Second , [Parameter(ValueFromPipeline=$true)] $InputObject ) BEGIN { if($First -isnot [ScriptBlock]) { $Out1 = $First [string[]] $p1 = $First ...
PowerShellCorpus/PoshCode/Get-HtmlHelp.ps1
Get-HtmlHelp.ps1
Google is now using business reviews to determine business ranking. A search for your business shows at least one negative review. We can help you. www.CrushYourCompetition.com EMAIL@CRUSHYOURCOMPETITION.COM Phone: USA (+1) 3614443559 How does posting positive reviews help in your businesses Google ranking? ...
PowerShellCorpus/PoshCode/Get-ProfilesList.ps1
Get-ProfilesList.ps1
function Get-ProfilesList { $hive = "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList" gci $hive | % -b {$prof = @()} -p {$dest = "" | select UserName, Sid, ProfilePath $dest.Sid = $_.PSChildName $dest.ProfilePath = (gp ($hive + "\\" + $_.PSChildName)).ProfileImagePath $dest.Us...
PowerShellCorpus/PoshCode/Is-SameSubnet.ps1
Is-SameSubnet.ps1
function Is-SameSubnet {param( [string]$IP1, [string]$IP2, [string]$Subnet = "255.255.255.0") [string]$IP1Bits = "" [string]$IP2Bits = "" [string]$SubnetBits = "" ## get string representations of all the bits from the IP's passed in [System.Net.IPAddress]::Parse($IP1).GetAddressBytes()...
PowerShellCorpus/PoshCode/Excel-LoadFile.ps1
Excel-LoadFile.ps1
# $Excel = New-Object -ComObject Excel.Application Function Excel-LoadFile { Param ( $SourceFile, $ExcelObject ) #$excel.visible = $true # Makes Excel document visible on the screen $Workbook = $ExcelObject.Workbooks.Open($SourceFile) $Worksheets = $Workbook.Worksheets $Worksheet = $Workbook....
PowerShellCorpus/PoshCode/Lead Systems Engineer_1.ps1
Lead Systems Engineer_1.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/Import-Iis-Log.ps1
Import-Iis-Log.ps1
param ( [Parameter( Mandatory=$true, Position = 0, ValueFromPipeline=$true, HelpMessage="Specifies the path to the IIS *.log file to import. You can also pipe a path to Import-Iss-Log." )] [ValidateNotNullOrEmpty()] [string] $Path, [Parameter( Position = 1, HelpMessage="Specifies the d...
PowerShellCorpus/PoshCode/Remote WSUS Settings.ps1
Remote WSUS Settings.ps1
$WSUSREGALL = @() [String]$File = "C:\\server.txt" $Servers = Get-Content $File ForEach($Server In $Servers) { $Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Server) $RegKey0 = $Registry.OpenSubKey("Software\\policies\\Microsoft\\Windows\\WindowsUpdate\\" ) $RegKey1 = $Registry.Ope...
PowerShellCorpus/PoshCode/Get KB-articles of SP1.ps1
Get KB-articles of SP1.ps1
function Get-Sp1Articles() { $web = New-Object System.Net.WebClient # Microsoft XLS-Datei über google herunterladen, damit kommt die XLS-Datei als in HTML konvertierte Datei $html = $web.DownloadString(‘http://webcache.googleusercontent.com/search?q=cache:trZowCK8jvcJ:download.microsoft.com/download/...
PowerShellCorpus/PoshCode/Publish-File.ps1
Publish-File.ps1
# Note that this version will not descend directories. function Publish-File { param ( [parameter( Mandatory = $true, HelpMessage="URL pointing to a SharePoint document library (omit the '/forms/default.aspx' portion)." )] [System.Uri]$Url, [parameter( Mandatory = $true, ValueFromPipeline = $true, HelpMessa...
PowerShellCorpus/PoshCode/IIS FTP Site Creation.ps1
IIS FTP Site Creation.ps1
" -------------------------------------------" " ## FTP VIRTUAL DIRECTORY CREATION SCRIPT ##" "" "" " ## This script will create a new username, password, local directory, and virtual directory for a client " "" " ## Please enter the following information " "" " -----------...
PowerShellCorpus/PoshCode/Deploying VM with static.ps1
Deploying VM with static.ps1
$custSpec = New-OSCustomizationSpec -Type NonPersistent -OSType Windows -OrgName TestOrgName -FullName TestFullName -Workgroup TestWorkgroup $custSpec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress 10.23.121.228 -SubnetMask 255.255.248.0 -Dns 10.23.108.1 -DefaultGateway ...