full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/02 Help system/2Quotes.ps1
2Quotes.ps1
#Quotation Markes #Double quotes resolve the variable $i="PowerShell" "This is the variable $i, and $i Rocks!" 'This is the variable $i, and $i Rocks!' "This is the variable `$i, and $i Rocks!" $computerName="Client" Get-service -name bits -ComputerName "$ComputerName" | Select MachineName, Name, Sta...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/02 Help system/7Do_While.ps1
7Do_While.ps1
# Do loop $i= 1 Do { Write-Output "PowerShell is Great! $i" $i=$i+1 # $i++ } While ($i -le 5) #Also Do-Until # While Loop $i=5 While ($i -ge 1) { Write-Output "Scripting is great! $i" $i-- }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/02 Help system/_Startup.ps1
_Startup.ps1
ise -file ".\1Var.ps1, .\2Quotes.ps1, .\3ObjectMembers.ps1, .\4Parenthesis.ps1, .\5If.ps1, .\6Switch.ps1, .\7Do_While.ps1, .\8For_Foreach.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/02 Help system/1Var.ps1
1Var.ps1
#Variables to store your stuff #Assigning a variable $MyVar=2 ${My Var}="Hello" #Output a variable $MyVar ${My Var} Write-Output $MyVar #Strongly type a variable [String]$MyName="Jason" [int]$Oops="Jason" [string]$ComputerName=Read-host "Enter Computer Name" Write-Output $ComputerName
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/07 prepping for automation/2Start.ps1
2Start.ps1
<# .Synopsis This function will gather basic computer information .Description This function will gather basic computer information From multiple computers and provide error logging information .Parameter ComputerName This parameter supports multiple computer names to gather Data from. This parameter is Mandato...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/07 prepping for automation/4BettertryCatch.ps1
4BettertryCatch.ps1
<# .Synopsis This function will gather basic computer information .Description This function will gather basic computer information From multiple computers and provide error logging information .Parameter ComputerName This parameter supports multiple computer names to gather Data from. This parameter is Mandato...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/07 prepping for automation/1erroraction.ps1
1erroraction.ps1
$ErrorActionPreference Get-WmiObject win32_bios -ComputerName DC,NotOnline,Client Get-WmiObject win32_bios -ComputerName DC,NotOnline,Client -EA SilentlyContinue -EV MyError $MyError Get-WmiObject win32_bios -ComputerName DC,NotOnline,Client -EA Stop Get-WmiObject win32_bios -ComputerName DC,NotOnline,Clie...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/07 prepping for automation/Tempalte.ps1
Tempalte.ps1
<# .Synopsis This function will gather basic computer information .Description This function will gather basic computer information From multiple computers and provide error logging information .Parameter ComputerName This parameter supports multiple computer names to gather Data from. This parameter is Mandato...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/07 prepping for automation/3SimpleTryCatch.ps1
3SimpleTryCatch.ps1
$Computer='notonline' Try{ $os=Get-Wmiobject -ComputerName $Computer -Class Win32_OperatingSystem ` -ErrorAction Stop -ErrorVariable CurrentError } Catch{ Write-warning "You done made a boo-boo with computer $Computer" }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/07 prepping for automation/_Startup.ps1
_Startup.ps1
ise -file ".\1erroraction.ps1, .\2Start.ps1, .\3SimpleTryCatch.ps1, .\4BettertryCatch.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/08 automation in scale/2SetVolName.ps1
2SetVolName.ps1
function Set-VolLabel { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium')] Param ( [Parameter(Mandatory=$True)] [String]$ComputerName, [Parameter(Mandatory=$True)] [String]$Label ) Process { if ($pscmdlet.ShouldProcess("$Compu...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/08 automation in scale/1SimpleExample.ps1
1SimpleExample.ps1
Function set-stuff{ [cmdletbinding(SupportsShouldProcess=$true, confirmImpact='Medium')] param( [Parameter(Mandatory=$True)] [string]$computername ) Process{ If ($psCmdlet.shouldProcess("$Computername")){ Write-Output 'Im changing...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/08 automation in scale/Launch.ps1
Launch.ps1
#Importing module from current location Import-Module C:\scripts\mod3\DiskInfo.psm1 #Remove module and re-import during testing Remove-Module Diskinfo;Import-Module C:\scripts\mod3\DiskInfo.psm1 #Putting the module in its proper place $Path=$env:PSModulePath -split ";" $Path[0] $ModulePath=$Path[0] + "\...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/08 automation in scale/_Startup.ps1
_Startup.ps1
ise -file ".\1SimpleExample.ps1, .\2SetVolName.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/04 objects for admin/6MakeObjects.ps1
6MakeObjects.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [String[]]$ComputerName, #Switch to turn on Error logging [Switch]$ErrorLog, [String]$LogFile = 'c:\errorlog.txt' ) Begin{ If($errorLog){ Write-V...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/04 objects for admin/5MainCodeEnd.ps1
5MainCodeEnd.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [String[]]$ComputerName, #Switch to turn on Error logging [Switch]$ErrorLog, [String]$LogFile = 'c:\errorlog.txt' ) Begin{ If($errorLog){ Write-V...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/04 objects for admin/3testparamEnd.ps1
3testparamEnd.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [String[]]$ComputerName, #Switch to turn on Error logging [Switch]$ErrorLog, [String]$LogFile = 'c:\errorlog.txt' ) Begin{ If($errorLog){ Write...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/04 objects for admin/1SimpleTemp.ps1
1SimpleTemp.ps1
<# Comment based help #> Function Verb-Noun { [CmdletBinding()] Param( [Parameter()][String]$MyString, [Parameter()][Int]$MyInt ) Begin{<#Code#>} Process{<#Code#>} End{<#Code#>} }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/04 objects for admin/4MainCodeStart.ps1
4MainCodeStart.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [String[]]$ComputerName, #Switch to turn on Error logging [Switch]$ErrorLog, [String]$LogFile = 'c:\errorlog.txt' ) Begin{ If($errorLog){ Write-V...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/04 objects for admin/2testparamStart.ps1
2testparamStart.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [String]$ComputerName, #Switch to turn on Error logging [Switch]$ErrorLog, [String]$LogFile = 'c:\errorlog.txt' ) Begin{} Process{} End{} }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/04 objects for admin/_Startup.ps1
_Startup.ps1
ise -file ".\1SimpleTemp.ps1, .\2testparamStart.ps1, .\3testparamEnd.ps1, .\4MainCodeStart.ps1, .\5MainCodeEnd.ps1, .\6MakeObjects.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/09 intro scripting/MyTools.ps1
MyTools.ps1
<# .Synopsis This function will gather basic computer information .Description This function will gather basic computer information From multiple computers and provide error logging information .Parameter ComputerName This parameter supports multiple computer names to gather Data from. This parameter is Mandato...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/09 intro scripting/Manifest.ps1
Manifest.ps1
New-ModuleManifest -Path 'C:\Users\student.COMPANY\Documents\WindowsPowerShell\Modules\MyTools\MyTools.psd1' ` -Author Jason -CompanyName MyCompany -Copyright '(c)2013 JumpStart' ` -ModuleVersion 1.0 -Description 'The JumpStart module' ` -PowerShellVersion 3.0 -RootModule .\MyTools.psm1
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/09 intro scripting/WithView.ps1
WithView.ps1
<# .Synopsis This function will gather basic computer information .Description This function will gather basic computer information From multiple computers and provide error logging information .Parameter ComputerName This parameter supports multiple computer names to gather Data from. This parameter is Mandato...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/09 intro scripting/Launch.ps1
Launch.ps1
#Importing module from current location Import-Module C:\scripts\mod9\MyTools.psm1 # Listing the commands Get-Command -Module MyTools #Remove module and re-import during testing Remove-Module MyTools;Import-Module C:\scripts\mo93\DiskInfo.psm1 #Putting the module in its proper place $Path=$env:PSModulePa...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/09 intro scripting/_Startup.ps1
_Startup.ps1
ise -file ".\MyTools.ps1, .\Launch.ps1, .\Manifest.ps1, .\WithView.ps1, .\MAnifestview.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/09 intro scripting/Manifestview.ps1
Manifestview.ps1
New-ModuleManifest -Path 'C:\Users\student.COMPANY\Documents\WindowsPowerShell\Modules\MyTools\MyTools.psd1' ` -Author Jason -CompanyName MyCompany -Copyright '(c)2013 JumpStart' ` -ModuleVersion 1.0 -Description 'The JumpStart module' ` -PowerShellVersion 3.0 -RootModule .\MyTools.psm1 -FormatsToProcess .\JasonType...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/4ParamAlias.ps1
4ParamAlias.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [Parameter(Mandatory=$True, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, HelpMessage= 'One or more computer names')] ...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/7ParamPattern.ps1
7ParamPattern.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [Parameter(Mandatory=$True, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [String[]]$ComputerName, [ValidatePattern("\b\d{1,3}\...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/5ParamSet.ps1
5ParamSet.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [Parameter(Mandatory=$True, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [ValidateSet('DC','Client')] [String[]]$ComputerName, ...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/3ParamHelp.ps1
3ParamHelp.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [Parameter(Mandatory=$True, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, HelpMessage= 'One or more computer names')] ...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/2Pipeline.ps1
2Pipeline.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [Parameter(Mandatory=$True, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [String[]]$ComputerName, #Switch to turn on E...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/1Mandatory.ps1
1Mandatory.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers #[Parameter(Mandatory=$True)] [String[]]$ComputerName, #Switch to turn on Error logging [Switch]$ErrorLog, [String]$LogFile = 'c:\errorlog.txt' ) Begin{...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/6ParamCount.ps1
6ParamCount.ps1
Function Get-CompInfo{ [CmdletBinding()] Param( #Want to support multiple computers [Parameter(Mandatory=$True, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [ValidateCount(0,2)] [String[]]$ComputerName, ...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/05 pipeline deeper/_Startup.ps1
_Startup.ps1
ise -file ".\1Mandatory.ps1, .\2Pipeline.ps1, .\3ParamHelp.ps1,.\4ParamAlias.ps1, .\5ParamSet.ps1, .\6ParamCount.ps1, .\7ParamPattern.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/06 remoting/1PlacingHelp.ps1
1PlacingHelp.ps1
<# .Synopsis This is the short description #> Function Get-TestHelp{ [CmdletBinding()] param() Begin{} Process{} End{} }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/06 remoting/2CommentbasedHelp.ps1
2CommentbasedHelp.ps1
<# .Synopsis This function will gather basic computer information .Description This function will gather basic computer information From multiple computers and provide error logging information .Parameter ComputerName This parameter supports multiple computer names to gather Data from. This parameter is Mandato...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/06 remoting/_Startup.ps1
_Startup.ps1
ise -file ".\1PlacingHelp.ps1, .\2CommentbasedHelp.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/03 pipeline/2SettingVars.ps1
2SettingVars.ps1
#Choose values to replace with variables [String]$ComputerName='Client' [String]$Drive='c:' Get-WmiObject -class Win32_logicalDisk -Filter "DeviceID='$Drive'" -ComputerName $ComputerName
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/03 pipeline/DiskInfo.ps1
DiskInfo.ps1
# Making a function Function Get-DiskInfo{ [CmdletBinding()] param( [Parameter(Mandatory=$true)] [String]$ComputerName, [String]$Drive='c:' ) Get-WmiObject -class Win32_logicalDisk -Filter "DeviceID='$Drive'" -ComputerName $ComputerName | Select PSComputerName,...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/03 pipeline/3Params.ps1
3Params.ps1
# add the Param block #[CmdletBinding()] param( [String]$ComputerName='Client', [String]$Drive='c:' ) Get-WmiObject -class Win32_logicalDisk -Filter "DeviceID='$Drive'" -ComputerName $ComputerName
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/03 pipeline/JumpTools.ps1
JumpTools.ps1
Function Get-DiskInfo{ [CmdletBinding()] param( [Parameter(Mandatory=$true)] [String]$ComputerName, [String]$Drive='c:' ) Get-WmiObject -class Win32_logicalDisk -Filter "DeviceID='$Drive'" -ComputerName $ComputerName | Select PSComputerName, DeviceID, ...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/03 pipeline/2CompleteTemp.ps1
2CompleteTemp.ps1
<# .Synopsis Short description .DESCRIPTION Long description .EXAMPLE Example of how to use this cmdlet .EXAMPLE Another example of how to use this cmdlet .INPUTS Inputs to this cmdlet (if any) .OUTPUTS Output from this cmdlet (if any) .NOTES General notes .COMPONENT The componen...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/03 pipeline/1StartCmd.ps1
1StartCmd.ps1
# Start with a command # I like to start in the console Get-WmiObject -class Win32_logicalDisk -Filter "DeviceID='C:'" -ComputerName 'localhost' # The new CIM version if you like Get-CimInstance -ClassName win32_logicalDisk -Filter "DeviceID='C:'" -ComputerName 'localhost' #Might even dress it up Get-WmiObject -...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/MVA Jump start course scripts/03 pipeline/_Startup.ps1
_Startup.ps1
ise -file ".\1StartCmd.ps1, .\2SettingVars.ps1, .\3Params.ps1, .\DiskInfo.ps1, .\JumpTools.ps1"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/ListProcessesSortResults.ps1
ListProcessesSortResults.ps1
<#The ListProcessesSortResults.ps1 script is a script that a network administrator might want to schedule to run several times a day. It produces a list of currently running processes and writes the results to a text file as a formatted and sorted table #> $args = "localhost","loopback","127.0.0.1" foreach ($i in...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/AccountsWithNoRequiredPassword.ps1
AccountsWithNoRequiredPassword.ps1
$args = "localhost" foreach ($i in $args) {Write-Host "Connecting to" $i "please wait ..."; Get-WmiObject -computername $i -class win32_UserAccount | Select-Object Name, Disabled, PasswordRequired, SID, SIDType | Where-Object {$_.PasswordRequired -eq 0} | Sort-Object -property name}
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoSwitchArray.ps1
DemoSwitchArray.ps1
$a = 2,3,5,1,77 Switch ($a) { 1 { ‘$a = 1’ } 2 { ‘$a = 2’ } 3 { ‘$a = 3’ } Default { ‘unable to determine value of $a’ } } "Statement after switch"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoWhileLessThan.ps1
DemoWhileLessThan.ps1
$i = 0 While ($i -lt 5) { "`$i equals $i. This is less than 5" $i++ } #end while $i lt 5
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/demoIfElseIfElse.ps1
demoIfElseIfElse.ps1
$a = 4 If ($a -eq 5) { ‘$a equals 5’ } ElseIf ($a -eq 3) { ‘$a is equal to 3’ } Else { ‘$a does not equal 3 or 5’ }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoBreakFor.ps1
DemoBreakFor.ps1
$ary = 1..5 ForEach($i in $ary) { if($i -eq 3) { break } $i } "Statement following foreach loop"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DirectoryListWithArguments.ps1
DirectoryListWithArguments.ps1
#The DirectoryListWithArguments.ps1 script takes a single, unnamed argument that allows #the script to be modified when it is run. This makes the script much easier to work with and #adds flexibility. foreach ($i in $args) {Get-ChildItem $i | Where-Object length -gt 1000 | Sort-Object -property name}
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoIf.ps1
DemoIf.ps1
$a = 5 If($a -eq 5) { ‘$a equals 5’ }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoSwitchMultiMatch.ps1
DemoSwitchMultiMatch.ps1
$a = 2 Switch ($a) { 1 { ‘$a = 1’ } 2 { ‘$a = 2’ } 2 { ‘Second match of the $a variable’ } 3 { ‘$a = 3’ } Default { ‘unable to determine value of $a’ } } "Statement after switch"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DisplayCapitalLetters.ps1
DisplayCapitalLetters.ps1
$i = 0 $caps = 65..91 do { [char]$caps[$i] $i++ } while ($i -lt 26)
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/demoIfElse.ps1
demoIfElse.ps1
$a = 4 If ($a -eq 5) { ‘$a equals 5’ } Else { ‘$a is not equal to 5’ }
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoForLoop.ps1
DemoForLoop.ps1
None
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoDoWhile.ps1
DemoDoWhile.ps1
$i = 0 $ary = 1..5 do { $ary[$i] $i++ } while ($i -lt 5)
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/DemoDoUntil.ps1
DemoDoUntil.ps1
$i = 0 $ary = 1..5 Do { $ary[$i] $i ++ } Until ($i -eq 5)
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/Get-TextStatisticsCallChildFunction.ps1
Get-TextStatisticsCallChildFunction.ps1
Function Get-TextStatistics($path) { Get-Content -path $path | Measure-Object -line -character -word Write-Path } Function Write-Path() { "Inside Write-Path the `$path variable is equal to $path" } Get-TextStatistics("C:\fso\test.txt") "Outside the Get-TextStatistics function `$path is equal to $path"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/Get-OperatingSystemVersion.ps1
Get-OperatingSystemVersion.ps1
Function Get-OperatingSystemVersion { (Get-WmiObject -Class Win32_OperatingSystem).Version } #end Get-OperatingSystemVersion "This OS is version $(Get-OperatingSystemVersion)"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/InLineGetIPDemo.ps1
InLineGetIPDemo.ps1
$IP = Get-WmiObject -class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = $true" "IP Address: " + $IP.IPAddress[0] "Subnet: " + $IP.IPSubNet[0] "GateWay: " + $IP.DefaultIPGateway "DNS Server: " + $IP.DNSServerSearchOrder[0] "FQDN: " + $IP.DNSHostName + "." + $IP.DNSDomain
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/BusinessLogicDemo.ps1
BusinessLogicDemo.ps1
Function Get-Discount([double]$rate,[int]$total) { $rate * $total } #end Get-Discount $rate = .05 $total = 100 $discount = Get-Discount -rate $rate -total $total "Total: $total" "Discount: $discount" "Your Total: $($total-$discount)"
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/FindLargeDocs.ps1
FindLargeDocs.ps1
Function Get-Doc($path) { Get-ChildItem -Path $path -include *.doc,*.docx,*.dot -recurse } #end Get-Doc Filter LargeFiles($size) { $_ | Where-Object { $_.length -ge $size } } #end LargeFiles Get-Doc("C:\FSO") | LargeFiles 1000
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/GetIPDemoSingleFunction.ps1
GetIPDemoSingleFunction.ps1
Function Get-IPDemo { $IP = Get-WmiObject -class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = $true" "IP Address: " + $IP.IPAddress[0] "Subnet: " + $IP.IPSubNet[0] "GateWay: " + $IP.DefaultIPGateway "DNS Server: " + $IP.DNSServerSearchOrder[0] "FQDN: " + $IP.DNSHostName + "." + $IP.DNSDomain } #end G...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/Get-DirectoryListingToday.ps1
Get-DirectoryListingToday.ps1
Function Get-DirectoryListing { Param( [String]$Path, [String]$Extension = "txt", [Switch]$Today ) If($Today) { Get-ChildItem -Path $path\* -include *.$Extension | Where-Object { $_.LastWriteTime -ge (Get-Date).Date } } ELSE { Get-ChildItem -Path $path\* -include *.$Extension } } #end Get-DirectoryListi...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/Resolve-ZipCode.ps1
Resolve-ZipCode.ps1
#Requires -Version 2.0 Function Resolve-ZipCode([int]$zip) { $URI = "http://www.webservicex.net/uszip.asmx?WSDL" $zipProxy = New-WebServiceProxy -uri $URI -namespace WebServiceProxy -class ZipClass $zipProxy.getinfobyzip($zip).table } #end Get-ZipCode Resolve-ZipCode 28273
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/FunctionGetIPDemo.ps1
FunctionGetIPDemo.ps1
Function Get-IPObject { Get-WmiObject -class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = $true" } #end Get-IPObject Function Format-IPOutput($IP) { "IP Address: " + $IP.IPAddress[0] "Subnet: " + $IP.IPSubNet[0] "GateWay: " + $IP.DefaultIPGateway "DNS Server: " + $IP.DNSServerSearchOrder[0] "FQDN: "...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/Get-IPObjectDefaultEnabledFormatNonIPOutput.ps1
Get-IPObjectDefaultEnabledFormatNonIPOutput.ps1
Function Get-IPObject([bool]$IPEnabled = $true) { Get-WmiObject -class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = $IPEnabled" } #end Get-IPObject Function Format-NonIPOutput($IP) { Begin { "Index # Description" } Process { ForEach ($i in $ip) { Write-Host $i.Index `t $i.Description } #end ForEach...
PowerShellCorpus/Github/lilswif_School2015/Systeembeheer/deelopdracht Powershell - Online course + Boek/Boek Kjeld/scripts/functions/DemoTrapSystemException.ps1
DemoTrapSystemException.ps1
Function My-Test([int]$myinput) { "It worked" } #End my-test function # *** Entry Point to Script *** Trap [SystemException] { "error trapped" ; continue } My-Test -myinput "string" "After the error"
PowerShellCorpus/Github/KenHoover_O365-LicenseManagement/disable-O365ServicePlan.ps1
disable-O365ServicePlan.ps1
# disable-O365serviceplan.ps1 # # by Ken Hoover <ken.hoover@yale.edu> for Yale University # March 2017 # Turns "off" the service plan listed in $targetServicePlan for $userPrincipalName if it's currently enabled. # IMPORTANT ** REMOVING SERVICE PLANS CAN RESULT IN DATA LOSS. BE CAREFUL. ** # Assumes that w...
PowerShellCorpus/Github/KenHoover_O365-LicenseManagement/enable-O365ServicePlan.ps1
enable-O365ServicePlan.ps1
# enable-O365ServicePlan.ps1 # # by Ken Hoover <ken.hoover@yale.edu> for Yale University # March 2017 # Turns "on" the service plan listed in $targetServicePlan for $userPrincipalName if it's currently disabled. # Assumes that we are already connected to the target O365 environment (via connect-msolservice). ...
PowerShellCorpus/Github/matt9ucci_PSProfiles/profile.ps1
profile.ps1
function sl.. { sl .. } function sl~ { sl ~ } sal gh help sal gcb Get-Clipboard sal scb Set-Clipboard sal cd.. sl.. sal cd~ sl~ function ll([string[]]$Path = '.') { gci $Path -Exclude .* } sal d docker sal dm docker-machine sv DESKTOP $HOME\Desktop -Option ReadOnly, AllScope sv DOWNLOADS $HOME\Downlo...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Microsoft.PowerShell_profile.ps1
Microsoft.PowerShell_profile.ps1
PowerShellCorpus/Github/matt9ucci_PSProfiles/Microsoft.PowerShellISE_profile.ps1
Microsoft.PowerShellISE_profile.ps1
PowerShellCorpus/Github/matt9ucci_PSProfiles/Modules/EnvironmentVariable/PATH.ps1
PATH.ps1
function Get-PathEnv { Param( [System.EnvironmentVariableTarget]$Target = [System.EnvironmentVariableTarget]::Process ) return ([System.Environment]::GetEnvironmentVariable('PATH', $Target).Split(';')) } function Set-PathEnv { Param( [string[]]$Path, [System.EnvironmentVariableTarget]$Target = [S...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Modules/EnvironmentVariable/HttpProxy.ps1
HttpProxy.ps1
function Set-HttpProxyEnv { Param( [System.EnvironmentVariableTarget]$Target = [System.EnvironmentVariableTarget]::Process, [Parameter(Mandatory = $true)] [string]$Server, [Parameter(Mandatory = $true)] [string]$Port ) $proxy = "${Server}:${Port}" $user = Read-Host 'What is your proxy user?' ...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Modules/VirtualBox/MachineConfiguration.ps1
MachineConfiguration.ps1
. (Join-Path $PSScriptRoot VirtualBoxSDKEnums.ps1) function New-VBoxMachine { Param( [Parameter(Mandatory = $true)][string]$Name, [Parameter(Mandatory = $true)][string]$Path ) $j = Get-Content $Path | ConvertFrom-Json $m = $vbox.CreateMachine($null, $Name, [string[]]$j.Groups, $j.OSTypeId, $null) ...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Modules/VirtualBox/VirtualBoxSDKEnums.ps1
VirtualBoxSDKEnums.ps1
enum ClipboardMode { Disabled = 0 HostToGuest = 1 GuestToHost = 2 Bidirectional = 3 } enum DnDMode { Disabled = 0 HostToGuest = 1 GuestToHost = 2 Bidirectional = 3 } enum KeyboardHIDType { None = 1 PS2Keyboard = 2 USBKeyboard = 3 ComboKeyboard = 4 } enu...
PowerShellCorpus/Github/matt9ucci_PSProfiles/init/Initialize-Windows.ps1
Initialize-Windows.ps1
Push-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\ Set-ItemProperty -Path Explorer\Advanced -Name TaskbarSmallIcons -Value 1 Pop-Location
PowerShellCorpus/Github/matt9ucci_PSProfiles/init/Install-GoTools.ps1
Install-GoTools.ps1
go get -u -v github.com/nsf/gocode go get -u -v github.com/rogpeppe/godef go get -u -v github.com/golang/lint/golint go get -u -v github.com/lukehoban/go-outline go get -u -v github.com/tpng/gopkgs go get -u -v golang.org/x/tools/cmd/gorename go get -u -v sourcegraph.com/sqs/goreturns go get -u -v github.com/new...
PowerShellCorpus/Github/matt9ucci_PSProfiles/init/Out-UserJsToFirefoxProfile.ps1
Out-UserJsToFirefoxProfile.ps1
Param( [Parameter(Mandatory = $true)] [string]$Name ) ipmo Firefox $content = @" user_pref("browser.tabs.warnOnClose", false); user_pref("browser.tabs.warnOnCloseOtherTabs", false); user_pref("browser.tabs.closeWindowWithLastTab", false); user_pref("browser.tabs.showAudioPlayingIcon", false); user_pref(...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Scripts/Install.ps1
Install.ps1
$d = Join-Path $DOWNLOADS "Installer" $install = @{ # http://www.7-zip.org/faq.html '7-Zip' = { & "$d\7z1604-x64.exe" /S } 'npp' = { Expand-Archive -Path $d\npp.7.4.1.bin.x64.zip -DestinationPath C:\Apps\Notepad++ } # https://wiki.videolan.org/Documentation:Installing_VLC/ 'VLC' = { & "$d\vlc-2.2.6-win64.e...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Scripts/Assert-FileHash.ps1
Assert-FileHash.ps1
[CmdletBinding()] param( [string]$Path, [ValidateSet('SHA256', 'MD5', 'SHA1', 'SHA384', 'SHA512', 'MACTripleDES', 'RIPEMD160')] [string]$Algorithm = 'SHA256', [string]$Hash ) $fileHash = Get-FileHash -Path $Path -Algorithm $Algorithm Write-Verbose ("Comparing {0} with {1}" -f $fileHash, $Hash) $fileHas...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Scripts/Install-DockerMachine.ps1
Install-DockerMachine.ps1
[CmdletBinding()] param( [string]$Version ) $fileName = 'docker-machine.exe' if (Get-Command $fileName -ErrorAction SilentlyContinue) { Write-Warning "$fileName already exists" return } if (!$Version) { $latest = Invoke-RestMethod -Uri "https://api.github.com/repos/docker/machine/releases/latest" -Met...
PowerShellCorpus/Github/matt9ucci_PSProfiles/Scripts/Save-DockerBin.ps1
Save-DockerBin.ps1
# See https://developer.github.com/v3/repos/releases/#get-the-latest-release $latest = Invoke-RestMethod -Uri "https://api.github.com/repos/docker/docker/releases/latest" -Method Get if ($latest.body | where { $_ -match "https://get.docker.com/builds/Windows/x86_64/.*.zip" }) { $uri = $Matches[0] $outFile = Joi...
PowerShellCorpus/Github/fbandres_GetADComputerInfo/GetADComputerInfo.ps1
GetADComputerInfo.ps1
############################################################################################################## # # Title: GetADComputerInfo # Author: Francis Paulo B. Andres # Website: http://francisandres.com # Description: Get Active Directory Computer Information from a CSV file. # ###########################...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/jQuery.1.10.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Determine the file paths $projectIntelliSenseFilePath = Join-Path $projectScriptsFolderPath $intelliSenseFileName $origIntelliSenseFilePath = Join-Path $toolsPath $intelliSenseFileName if (Test-Path $projectIntelliSense...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/jQuery.1.10.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # VS 11 and above supports the new intellisense JS files $vsVersion = [System.Version]::Parse($dte.Version) $supportsJsIntelliSenseFile = $vsVersion.Major -ge 11 if (-not $supportsJsIntelliSenseFile) { $displayVersio...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/jQuery.1.10.2/Tools/common.ps1
common.ps1
function Get-Checksum($file) { $cryptoProvider = New-Object "System.Security.Cryptography.MD5CryptoServiceProvider" $fileInfo = Get-Item $file trap { ; continue } $stream = $fileInfo.OpenRead() if ($? -eq $false) { # Couldn't open file for reading return $null } $bytes = $...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/Modernizr.2.6.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Update the _references.js file Remove-Reference $scriptsFolderProjectItem $modernizrFileNameRegEx
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/Modernizr.2.6.2/Tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) if ($scriptsFolderProjectItem -eq $null) { # No Scripts folder Write-Host "No Scripts folder found" exit } # Update the _references.js file AddOrUpdate-Reference $scriptsFolderProjectItem $modernizrFileName...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/Modernizr.2.6.2/Tools/common.ps1
common.ps1
function AddOrUpdate-Reference($scriptsFolderProjectItem, $fileNamePattern, $newFileName) { try { $referencesFileProjectItem = $scriptsFolderProjectItem.ProjectItems.Item("_references.js") } catch { # _references.js file not found return } if ($referencesFileProject...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/EntityFramework.6.1.1/tools/init.ps1
init.ps1
param($installPath, $toolsPath, $package, $project) if (Get-Module | ?{ $_.Name -eq 'EntityFramework' }) { Remove-Module EntityFramework } Import-Module (Join-Path $toolsPath EntityFramework.psd1) # SIG # Begin signature block # MIIa4AYJKoZIhvcNAQcCoIIa0TCCGs0CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQ...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/EntityFramework.6.1.1/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) Initialize-EFConfiguration $project Add-EFProvider $project 'System.Data.SqlClient' 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' Write-Host Write-Host "Type 'get-help EntityFramework' to see all available Entity Framework comma...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/WebService/packages/Newtonsoft.Json.6.0.3/tools/install.ps1
install.ps1
param($installPath, $toolsPath, $package, $project) # open json.net splash page on package install # don't open if json.net is installed as a dependency try { $url = "http://james.newtonking.com/json" $dte2 = Get-Interface $dte ([EnvDTE80.DTE2]) if ($dte2.ActiveWindow.Caption -eq "Package Manager Con...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/Rock-Paper-Scissors/packages/Bitrium.Http.Extensions.1.1.0/tools/init.ps1
init.ps1
# Runs the first time a package is installed in a solution, and every time the solution is opened. param($installPath, $toolsPath, $package, $project) # $installPath is the path to the folder where the package is installed. # $toolsPath is the path to the tools directory in the folder where the package is instal...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/Rock-Paper-Scissors/packages/Bitrium.Http.Extensions.1.1.0/tools/uninstall.ps1
uninstall.ps1
# Runs every time a package is uninstalled param($installPath, $toolsPath, $package, $project) # $installPath is the path to the folder where the package is installed. # $toolsPath is the path to the tools directory in the folder where the package is installed. # $package is a reference to the package object. ...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/Rock-Paper-Scissors/packages/Bitrium.Http.Extensions.1.1.0/tools/install.ps1
install.ps1
# Runs every time a package is installed in a project param($installPath, $toolsPath, $package, $project) # $installPath is the path to the folder where the package is installed. # $toolsPath is the path to the tools directory in the folder where the package is installed. # $package is a reference to the packag...
PowerShellCorpus/Github/EndersonSalas_Challenge-Rock-Paper-Scissors/Rock-Paper-Scissors/packages/jQuery.1.10.2/Tools/uninstall.ps1
uninstall.ps1
param($installPath, $toolsPath, $package, $project) . (Join-Path $toolsPath common.ps1) # Determine the file paths $projectIntelliSenseFilePath = Join-Path $projectScriptsFolderPath $intelliSenseFileName $origIntelliSenseFilePath = Join-Path $toolsPath $intelliSenseFileName if (Test-Path $projectIntelliSense...