full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/Github/kinshines_Pro.ASP.NET.MVC.5.Platform/Chapter 14/Users/packages/jQuery.1.9.0/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/kinshines_Pro.ASP.NET.MVC.5.Platform/Chapter 14/Users/packages/EntityFramework.6.1.0/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
# MIIarwYJKoZIhvcNAQcCoIIaoDCCGpwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQ... |
PowerShellCorpus/Github/kinshines_Pro.ASP.NET.MVC.5.Platform/Chapter 14/Users/packages/EntityFramework.6.1.0/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/kinshines_Pro.ASP.NET.MVC.5.Platform/Chapter 03/SimpleApp/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/kinshines_Pro.ASP.NET.MVC.5.Platform/Chapter 03/SimpleApp/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/kinshines_Pro.ASP.NET.MVC.5.Platform/Chapter 03/SimpleApp/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/RePierre_powershell-utils/utils.ps1 | utils.ps1 | function Get-ScriptDirectory
{
$invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $invocation.MyCommand.Path
}
function Deploy-Files($sourceDir, $destinationDir, $filter)
{
Write-Host "Searching in: " $sourceDir
$files = Get-ChildItem -LiteralPath $sourceDir -Filter $filter
ForEach($fil... |
PowerShellCorpus/Github/OPS-E2E-PPE_E2E_D_NewRepo_2017_5_19_19_58_31/.openpublishing.build.ps1 | .openpublishing.build.ps1 | param(
[string]$buildCorePowershellUrl = "https://opbuildstorageprod.blob.core.windows.net/opps1container/.openpublishing.buildcore.ps1",
[string]$parameters
)
# Main
$errorActionPreference = 'Stop'
# Step-1: Download buildcore script to local
echo "download build core script to local with source url: ... |
PowerShellCorpus/Github/lhuwyler_SCVMM-cloud-service-helper/service_helper.ps1 | service_helper.ps1 | #==========================================================================#
# Manage SCVMM Cloud Services (Shutdown / Delete) #
#==========================================================================#
# #
# Change... |
PowerShellCorpus/Github/WhoDeyNation_321Project/Platek_U2_NewAdUser.ps1 | Platek_U2_NewAdUser.ps1 | # Bulk creating AD Users from a CSV file
# Created by Aaron Platek aaron.platek11@outlook.com
# Modules Required ActiveDirectory by adding windows feature
# Start of function
New-BulkADUser (OptionalParameters)
{
# CSV File containing AD Users to be created
$Csv = "<path>"
# Foreach Loop to create AD Us... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Check-Flags.ps1 | Check-Flags.ps1 | # https://knowledge.zomers.eu/PowerShell/Pages/How-to-control-UserAccountControl-Active-Directory-flags-with-PowerShell.aspx
function Check-Flags ($sam = $env:USERNAME) {
$uac = [int](([adsisearcher]"samaccountname=$sam").FindOne().Properties.useraccountcontrol | Out-String).Trim()
if ($uac -eq 0) {
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/PRobocopy.ps1 | PRobocopy.ps1 | function PRobocopy {
param (
[string]$Source = $PWD,
[string]$Destination = 'NULL',
[string[]]$Include,
[long]$Retries = 1000000,
[long]$WaitTime = 30,
[string]$ExcludeAttributes, # RASHCNETO
[switch]$ExcludeChanged,
[switch]$ExcludeNewer,
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Check-Header.ps1 | Check-Header.ps1 | # http://learningpcs.blogspot.com/2012/07/powershell-v3-check-file-headers.html
# https://en.wikipedia.org/wiki/List_of_file_signatures
# http://www.garykessler.net/library/file_sigs.html
function Check-Header {
param (
$path
)
$path = Resolve-FullPath $path
# Hexidecimal signa... |
PowerShellCorpus/Github/gangstanthony_PowerShell/convert file to bits.ps1 | convert file to bits.ps1 | function ConvertTo-Bytes {
param (
[string]$file
)
if (!$file -or !(Test-Path $file)) {
throw "file not found: '$file'"
}
[convert]::ToBase64String((Get-Content $file -Encoding Byte))
}
function ConvertFrom-Bytes {
param (
[string]$bytes,
[string... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Save-ExcelasCSV.ps1 | Save-ExcelasCSV.ps1 | # also see:
# http://www.codeproject.com/Articles/451744/Extract-worksheets-from-Excel-into-separate-files
# http://social.technet.microsoft.com/Forums/scriptcenter/en-US/4de7ed7a-f1b3-4e35-98b1-ef1f7f2ee7b2/powershell-export-from-excel-to-csv-having-delimiter?forum=ITCG
function Save-ExcelasCSV {
param (
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-PrinterHosts.ps1 | Get-PrinterHosts.ps1 |
# need admin rights
# if you include USB printers on workstations, it picks up peoples home usb printers as well...
# also including shared printers may include home printers
function Get-PrinterHosts {
Param (
[string]$comp = $env:COMPUTERNAME
)
if (!$comp) { throw 'No comps.' }
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Decode-Text.ps1 | Decode-Text.ps1 | # http://www.powershelladmin.com/wiki/Powershell_prompt_for_password_convert_securestring_to_plain_text
function Decode-Text {
param (
[string]$Text,
[validateset('SecureString', 'SecureStringWithKey', 'Base64', 'ASCII')]
[string]$Method = 'Base64'
)
process {
if ... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-Header.ps1 | Get-Header.ps1 | # http://learningpcs.blogspot.com/2012/07/powershell-v3-check-file-headers.html
# https://en.wikipedia.org/wiki/List_of_file_signatures
# http://www.garykessler.net/library/file_sigs.html
function Get-Header {
param (
[string]$path,
[int]$bits = 4
)
$path = Resolve-FullPath $... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-ShaHash.ps1 | Get-ShaHash.ps1 | function Get-ShaHash {
param (
[Parameter(ValueFromPipeline=$true)]
[string]$file,
[ValidateSet(1, 256, 384, 512)]
[int]$bit = 512
)
begin {
function Resolve-FullPath ([string]$Path) {
if ( -not ([IO.Path]::IsPathRooted($Path)) ) {
$Pat... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-Lines.ps1 | Get-Lines.ps1 | # https://www.reddit.com/r/PowerShell/comments/4payc9/confirm_file_length_and_format_before_loading/
# this should work, but why not use get-content?
# get-content -readlines 1000
# see 'streamwriter example...'
# !
# this
# $stream = New-Object System.IO.StreamReader -ArgumentList $file
# is the same type a... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-Shortcut.ps1 | Get-Shortcut.ps1 | # Get-Shortcut
#
# Arguments
# Description
# FullName
# Hotkey
# IconLocation = '%SystemRoot%\system32\SHELL32.dll,16' # printer
# RelativePath
# TargetPath
# WindowStyle
# WorkingDirectory
function Get-Shortcut {
param (
[parameter(mandatory=$true)]
[string]$Path
)
begi... |
PowerShellCorpus/Github/gangstanthony_PowerShell/ConvertTo-Bytes.ps1 | ConvertTo-Bytes.ps1 | function ConvertTo-Bytes {
param (
[string]$file
)
if (!$file -or !(Test-Path $file)) {
throw "file not found: '$file'"
}
[convert]::ToBase64String((Get-Content $file -Encoding Byte))
}
|
PowerShellCorpus/Github/gangstanthony_PowerShell/Write-Progress Example.ps1 | Write-Progress Example.ps1 | # need to move seconds left to its own parameter
<# https://www.reddit.com/r/PowerShell/comments/4goous/question_about_modules_info_bar/
$Host.PrivateData.ProgressBackgroundColor = $Host.UI.RawUI.BackgroundColor
$Host.PrivateData.ProgressBackgroundColor = 1..15 | Get-Random
$Host.PrivateData.ProgressForegroundCol... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-MyADObject.ps1 | Get-MyADObject.ps1 | # https://github.com/RamblingCookieMonster/PowerShell/blob/master/Get-ADSIObject.ps1
# http://www.ldapexplorer.com/en/manual/109010000-ldap-filter-syntax.htm
# alternate credentials
# https://www.reddit.com/r/PowerShell/comments/40zmmf/converting_a_vb_script_to_powershellabsolutely/
function Get-MADObject {
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-ShortPath.ps1 | Get-ShortPath.ps1 | filter Get-ShortPath {
param (
[Parameter(ValueFromPipeline=$true)]
[string]$obj
)
begin {
$fso = New-Object -ComObject Scripting.FileSystemObject
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObje... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-ChromeExtension.ps1 | Get-ChromeExtension.ps1 | # https://www.reddit.com/r/PowerShell/comments/5px71w/getting_chrome_extensions/
function Get-ChromeExtension {
param (
[string]$ComputerName = $env:COMPUTERNAME
)
Get-ChildItem "\\$ComputerName\c$\users\*\appdata\local\Google\Chrome\User Data\Default\Extensions\*\*\manifest.json" -ErrorAct... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Split-Join-Files.ps1 | Split-Join-Files.ps1 | # http://stackoverflow.com/questions/4533570/in-powershell-how-do-i-split-a-large-binary-file
# specify file name and size of each part (5mb)
# new files are like:
# c:\temp\file.txt.part1
function Split-File ([string]$inFile, [int]$bufSize = 5mb) {
$stream = [System.IO.File]::OpenRead($inFile)
$chunkNu... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-User.ps1 | Get-User.ps1 | ## INFO
# find last logged on user of remote computer
# https://www.reddit.com/r/PowerShell/comments/448gdx/noob_need_help_getting_a_list_with_all_xp/
# get-ciminstance is the successor, but it doesn't work for me...
# http://powershell.com/cs/forums/t/23349.aspx
# (gp "HKLM:\SOFTWARE\Microsoft\Windows\Curre... |
PowerShellCorpus/Github/gangstanthony_PowerShell/propmatch.ps1 | propmatch.ps1 | # only return properties whose value matches your search
# ex: get-mailbox 'user' | propmatch 'user'
# ex: (get-psdrive)[0] | propmatch 'alias' | fl
filter propmatch ([string]$match='') {
$props = @()
$obj = $_
$obj | gm -m *property | % { if ($obj.$($_.name) -match $match) {$props += [string]$_.nam... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Save-CSVasExcel.ps1 | Save-CSVasExcel.ps1 | function Save-CSVasExcel {
param (
[string]$CSVFile = $(Throw 'No file provided.')
)
BEGIN {
function Resolve-FullPath ([string]$Path) {
if ( -not ([System.IO.Path]::IsPathRooted($Path)) ) {
# $Path = Join-Path (Get-Location) $Path
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Encode-Text.ps1 | Encode-Text.ps1 | # http://www.powershelladmin.com/wiki/Powershell_prompt_for_password_convert_securestring_to_plain_text
# http://poshcode.org/116
# also see
# https://www.reddit.com/r/PowerShell/comments/5zio13/looking_for_a_method_of_encrypting_a_command_not/deyempf/
function Encode-Text {
param (
[string]$Text,... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Store-Creds.ps1 | Store-Creds.ps1 | # http://bsonposh.com/archives/338
function Store-Creds ($pwfile = "c:\temp\$env:USERNAME.txt") {
$Credential = Get-Credential -Credential $env:USERNAME
$Credential.Password | ConvertFrom-SecureString | Set-Content $pwfile
}
function Get-Creds ($User = $env:USERNAME, $pwfile = "c:\temp\$env:USERNAME.tx... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Copy-File.ps1 | Copy-File.ps1 | # http://stackoverflow.com/questions/2434133/progress-during-large-file-copy-copy-item-write-progress
# https://stackoverflow.com/questions/13883404/custom-robocopy-progress-bar-in-powershell
function Copy-File {
param (
[string]$Path,
[string]$Destination,
[switch]$Overwrite
)
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-ComputerShares.ps1 | Get-ComputerShares.ps1 | # http://stackoverflow.com/questions/15797198/powershell-get-a-list-of-network-machines
# switch -regex (NET.EXE VIEW) { "^\\\\(?<Name>\S+)\s+" {$matches.Name}}
# $shares = $(switch -regex (net view) { '^\\\\(?<Name>\S+)' {$matches.Name}}) | % {net view $_}
# do NOT need admin rights
# not reliable. tried once on... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-MappedDrives.ps1 | Get-MappedDrives.ps1 | function Get-MappedDrives {
param (
$computer = $env:COMPUTERNAME
)
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Users', $computer)
$reg.GetSubKeyNames() | ? {$_ -match '\d{4,5}$'} | % {
$sid = $_
$reg.OpenSubKey("$sid\Network").GetSubKeyNames() | % {
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/fastest event log.ps1 | fastest event log.ps1 | # https://www.reddit.com/r/PowerShell/comments/5hgr1g/help_getwinevent_filterxml_i_dont_get_it/
$a1 = New-Object System.Collections.ArrayList
$a2 = New-Object System.Collections.ArrayList
$a3 = New-Object System.Collections.ArrayList
$a4 = New-Object System.Collections.ArrayList
$a5 = New-Object System.Collectio... |
PowerShellCorpus/Github/gangstanthony_PowerShell/touch.ps1 | touch.ps1 | # http://superuser.com/questions/502374/equivalent-of-linux-touch-to-create-an-empty-file-with-powershell
function touch {
param (
[string]$file,
$date = '' # 2015-01-01
)
if ($file -eq $null) {
throw 'No filename supplied'
}
if (!$date) {
$date = Get-... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Out-Menu.ps1 | Out-Menu.ps1 | # https://www.reddit.com/r/PowerShell/comments/4ad8or/create_user_menus_from_objectsarrays/
# https://www.reddit.com/r/PowerShell/comments/49tqgx/need_some_help_with_an_automation_script_im/
# http://www.powertheshell.com/input_psv3/
<#
.Synopsis
This function provides a convenient way to convert a PowerSh... |
PowerShellCorpus/Github/gangstanthony_PowerShell/CopyTo-Image.ps1 | CopyTo-Image.ps1 | # recommend using png instead of jpg
function CopyTo-Image {
param (
[string]$file,
[string]$image
)
$date = date -f yyyyMMddHHmmss
$fileext = $file.split('.')[-1]
if ($fileext -eq 'zip') {
$zip = $file
} else {
$zip = "c:\temp\$date.zip"
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/diskfree.ps1 | diskfree.ps1 | # gwmi win32_volume is faster than win32_logicaldisk
# https://4sysops.com/archives/query-free-disk-space-details-of-remote-computers-using-powershell/
function diskfree {
Param (
[parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]]$ComputerName = $env:compu... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Enable-PSRemoting.ps1 | Enable-PSRemoting.ps1 | # Requires the PSRemoteRegistry module
# https://psremoteregistry.codeplex.com/
# https://blogs.technet.microsoft.com/heyscriptingguy/2006/06/21/how-can-i-use-windows-powershell-to-start-a-service-on-a-remote-computer/
# https://gallery.technet.microsoft.com/scriptcenter/Enable-PSRemoting-Remotely-6cedfcb0
fu... |
PowerShellCorpus/Github/gangstanthony_PowerShell/profile.ps1 | profile.ps1 | # more ideas
# https://github.com/sushihangover/SushiHangover-PowerShell/blob/master/Microsoft.PowerShell_profile.ps1
c:
cd\
# Runs all .ps1 files in this module's directory
Get-ChildItem -Path $PSScriptRoot\*.ps1 | ? name -NotMatch 'Microsoft.PowerShell_profile' | Foreach-Object { . $_.FullName }
$env:path... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-SNMPPrinterInfo.ps1 | Get-SNMPPrinterInfo.ps1 | function Get-SNMPPrinterInfo {
param (
[string[]]$printers
)
begin {
$snmp = New-Object -ComObject olePrn.OleSNMP
$ping = New-Object System.Net.NetworkInformation.Ping
}
process {
foreach ($printer in $printers) {
try {
$resu... |
PowerShellCorpus/Github/gangstanthony_PowerShell/notnull.ps1 | notnull.ps1 | # only return properties that do not contain a null value
# ex: get-mailbox 'user' | notnull
# ex: (get-psdrive)[0] | notnull | fl
filter notnull {
$props = @()
$obj = $_
$obj | gm -m *property | % { if ( $obj.$($_.name) ) {$props += $_.name} }
$obj | select $props
}
|
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-BitLockerInfo.ps1 | Get-BitLockerInfo.ps1 | # requires c:\pstools\psexec.exe
function Get-BitLockerInfo {
param (
$ComputerName = $env:COMPUTERNAME
)
$comp = [pscustomobject]@{
Name = $ComputerName
OS = Get-Os $ComputerName
}
$comp = $comp | select *,
@{n='User';e={''}},
@{n='BitLoc... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-Files.ps1 | Get-Files.ps1 | # https://thesurlyadmin.com/2014/08/04/getting-directory-information-fast/
# https://gallery.technet.microsoft.com/Get-AlphaFSChildItems-ff95f60f
# check here for single file copy
# http://serverfault.com/questions/52983/robocopy-transfer-file-and-not-folder
# https://social.technet.microsoft.com/Forums/windowsse... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Create-Shortcut.ps1 | Create-Shortcut.ps1 | # Create-Shortcut
#
# Create-Shortcut -Source C:\temp\test.txt -DestinationLnk C:\temp\test.txt.lnk
#
# Arguments
# Description
# FullName
# Hotkey
# IconLocation = '%SystemRoot%\system32\SHELL32.dll,16' # printer
# RelativePath
# TargetPath
# WindowStyle
# WorkingDirectory
function Create-Shortcut {
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/fastest foreach.ps1 | fastest foreach.ps1 | $a1 = New-Object System.Collections.ArrayList
$a2 = New-Object System.Collections.ArrayList
$a3 = New-Object System.Collections.ArrayList
$a4 = New-Object System.Collections.ArrayList
$a5 = New-Object System.Collections.ArrayList
$a6 = New-Object System.Collections.ArrayList
1..100 | % {
[void]$a1.add((Mea... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-Clipboard.ps1 | Get-Clipboard.ps1 |
if (gcm Get-Clipboard -ea 0) {
return
}
#https://www.reddit.com/r/PowerShell/comments/68jpzx/a_small_getclipboard_function_for_ps_before_v5/
<# http://stackoverflow.com/questions/34700427/quickly-create-a-list-of-strings
Add-Type -Assembly System.Windows.Forms | Out-Null
$clp = [Windows.Forms.Clipboard]... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-SNMPData.ps1 | Get-SNMPData.ps1 |
# get snmp description and name
function Get-SNMPData {
param (
[string]$ip
)
begin {
$ping = New-Object System.Net.NetworkInformation.Ping
$snmp = New-Object -ComObject olePrn.OleSNMP
}
process {
$info = [pscustomobject]@{
IP = $ip
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-IEVersion.ps1 | Get-IEVersion.ps1 | # http://powershell.org/wp/forums/topic/creating-a-array-of-info-for-remote-computers/#post-37990
function Get-IEVersion ($computer = $env:COMPUTERNAME) {
$version = 0
$keyname = 'SOFTWARE\Microsoft\Internet Explorer'
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-FolderSize.ps1 | Get-FolderSize.ps1 | # https://social.technet.microsoft.com/Forums/scriptcenter/en-US/333f63ca-a7e0-4d92-b18d-133fd4953af7/export-with-foreach-not-working-then-send?forum=ITCG
# http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/05/weekend-scripter-sorting-folders-by-size.aspx
# https://www.linkedin.com/pulse/technical-thursdays-... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-MAC.ps1 | Get-MAC.ps1 | # http://myitpath.blogspot.com/2010/03/net-and-netbios-name-resolution.html
# this gives an error if ip is IPv6 address
function Get-MAC ($comp = $env:computername) {
$ping = New-Object System.Net.NetworkInformation.Ping
$result = $ping.Send($comp)
if ($result.Status -eq 'Success') {
$ip =... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Create-LocalUser.ps1 | Create-LocalUser.ps1 |
# http://www.selfadsi.org/ads-attributes/user-userAccountControl.htm
function Create-LocalUser {
param (
[string]$computer = $env:computername,
[string]$fullname,
[string]$username,
[string]$password,
[switch]$passworddoesnotexpire,
[string]$addtogroup = '... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-PrinterClients.ps1 | Get-PrinterClients.ps1 | # KNOWN ISSUES:
# only finds printers that are *NOT* locally hosted
# if looking for all possible printers, might have to use Get-PrinterHosts as well
#
# REQUIRES:
# admin rights
function Get-PrinterClients {
Param (
[string]$comp = $env:COMPUTERNAME
)
if (!$comp) { throw 'No com... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-LogonStatus.ps1 | Get-LogonStatus.ps1 | # https://gallery.technet.microsoft.com/scriptcenter/Get-Remote-Logon-Status-d8c2318a
function Get-LogonStatus ($computer = $env:COMPUTERNAME) {
$hash = @{
Computer = $computer
Name = '-'
User = '-'
Status = '-'
}
$obj = gwmi win32_computersystem -ComputerName $co... |
PowerShellCorpus/Github/gangstanthony_PowerShell/youtube-dl.ps1 | youtube-dl.ps1 | # requires youtube-dl.exe, ffprobe.exe, and ffmpeg.exe to be in the c:\temp folder
function ydl {
param (
[string]$url = (Get-Clipboard),
[ValidateSet('audio', 'video')]
[string]$type = 'audio',
[switch]$u,
[string]$ydlpath = "$env:userprofile\Dropbox\Documents\PSScr... |
PowerShellCorpus/Github/gangstanthony_PowerShell/fix file path too long subst.ps1 | fix file path too long subst.ps1 | # examples
# http://stackoverflow.com/questions/37038378/powershell-using-alphafs-to-capture-path-names-longer-than-259-characters/37039096#37039096
# https://community.spiceworks.com/topic/1529112-path-too-long-error?page=1#entry-5663147
# https://www.reddit.com/r/PowerShell/comments/4jzm8g/running_into_long_folder... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-InstalledApps.ps1 | Get-InstalledApps.ps1 | function Get-InstalledApps {
param (
[Parameter(ValueFromPipeline=$true)]
[string[]]$ComputerName = $env:COMPUTERNAME,
[string]$NameRegex = ''
)
foreach ($comp in $ComputerName) {
$keys = '','\Wow6432Node'
foreach ($key in $keys) {
try {
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Expand-OU.ps1 | Expand-OU.ps1 | # usage:
# Expand-OU domain.com/company/sales/users
#
# output:
# OU=users,OU=sales,OU=company,DC=domain,DC=com
function Expand-OU ($searchroot) {
$searchrootarray = $searchroot.split('/') | ? {$_ -and $_ -notmatch '^(?:\s+)?$'}
$dn = ([adsi]"LDAP://$($searchrootarray[0])").distinguishedname.ToStrin... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-SKU.ps1 | Get-SKU.ps1 | ## INFO
# get SystemSKU of remote computer
# (gwmi -n root\wmi ms_systeminformation).systemsku
function Get-SKU {
param (
[object]$comps = $env:COMPUTERNAME
)
foreach ($computer in $comps) {
try {
# (gp 'HKLM:\HARDWARE\DESCRIPTION\System\BIOS').SystemSku
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Remote-Registry.ps1 | Remote-Registry.ps1 | # this is my own learning of accessing the registry on remote computers.
# for a more complete solution, i recommend https://psremoteregistry.codeplex.com/
function Set-RemoteRegistry {
param (
$comp = $env:COMPUTERNAME,
[ValidateSet('ClassesRoot', 'CurrentUser', 'LocalMachine', 'Users', 'Per... |
PowerShellCorpus/Github/gangstanthony_PowerShell/MTFv2.ps1 | MTFv2.ps1 | # INFO
# run the script in STEP 1 at the bottom as local administrator
# run the script outside the powershell IDE
# the HOUR in the new name depends on what time zone the script is run in.
# for releasing references to ComObjects later
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-BootConfigurationData.ps1 | Get-BootConfigurationData.ps1 | # https://www.reddit.com/r/PowerShell/comments/4fyfau/does_anyone_know_of_a_module_or_wrapper_for/
# must be admin
function Get-BootConfigurationData {
param (
$bcdeditpath = (Join-Path $env:SystemRoot 'system32\bcdedit.exe')
)
$bootconfigurationdata = iex $bcdeditpath
$bootconfigur... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Write-Object.ps1 | Write-Object.ps1 | # https://social.technet.microsoft.com/Forums/windowsserver/en-US/30663446-4091-4a1c-9de0-407046ccc39f/powershell-script-with-submenus-how-to-go-back?forum=winserverpowershell
# the title is not very descriptive, but it's basically write-host $($a | fl * | out-string)
function Write-Object {
param (
... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-FolderAccess.ps1 | Get-FolderAccess.ps1 | # Best to run as admin account or you might get "Attempted to perform an unauthorized operation" on folders you can't access.
# Depth 0 = only specified folder. # This used to be set to folder and recurse all subs
# Depth 1-6 = works for folder and it's children
# Filters groups by regex on name, not by "if it found... |
PowerShellCorpus/Github/gangstanthony_PowerShell/ConvertFrom-Bytes.ps1 | ConvertFrom-Bytes.ps1 | function ConvertFrom-Bytes {
param (
[string]$bytes,
[string]$savepath
)
$dir = Split-Path $savepath
if (!(Test-Path $dir)) {
md $dir | Out-Null
}
[convert]::FromBase64String($bytes) | Set-Content $savepath -Encoding Byte
}
|
PowerShellCorpus/Github/gangstanthony_PowerShell/Test-Port.ps1 | Test-Port.ps1 | # https://www.reddit.com/r/PowerShell/comments/47hvmx/how_to_tell_if_ip_address_is_a_printer/
# https://www.wikiwand.com/en/List_of_TCP_and_UDP_port_numbers
# 515 - printer # Line Printer Daemon (LPD), print service
# 135 - windows # Microsoft EPMAP (End Point Mapper), also known as DCE/RPC Locator service,[17] us... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-Firewall.ps1 | Get-Firewall.ps1 | ## INFO
# find firewall status of remote computer
function Get-Firewall {
param (
[object]$comps = $env:COMPUTERNAME
)
foreach ($computer in $comps) {
try {
# $status = (gp 'HKLM:\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile')... |
PowerShellCorpus/Github/gangstanthony_PowerShell/pingt.ps1 | pingt.ps1 | # pingt 8.8.8.8 -t
# ping forever and show the time of ping
function pingt {
param(
[Parameter(ValueFromPipeline=$true)]
$comp = $env:COMPUTERNAME,
$n = 4,
[switch]$t
)
if (!$comp) {Throw 'No host provided'}
function callping {
sleep 1
Wr... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Setup-Network.ps1 | Setup-Network.ps1 | # must be administrator
function Setup-Network {
param (
[switch]$dhcp,
$ip,
$mask,
$gateway,
$dns1,
$dns2
)
# check admin rights
$admin = reg query "HKU\S-1-5-19\Environment" 2>&1
if ($admin -match 'denied') { Throw 'You are not ad... |
PowerShellCorpus/Github/gangstanthony_PowerShell/sortprop.ps1 | sortprop.ps1 | # sorts properties by name.
# ex: get-mailbox 'user' | sortprop
# ex: (get-psdrive)[0] | sortprop
filter sortprop {
$obj = $_
$props = $obj | gm -m *property | % {$_.name} | sort
$obj | select $props
}
|
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-LocalAdmin.ps1 | Get-LocalAdmin.ps1 | # wmi
# https://gallery.technet.microsoft.com/scriptcenter/Get-remote-machine-members-bc5faa57
# adsi
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/7bf4e490-0f3f-4a33-8350-2e78a869f1ed/list-remote-local-admins?forum=winserverpowershell
# https://www.reddit.com/r/PowerShell/comments/49oemk/how_... |
PowerShellCorpus/Github/gangstanthony_PowerShell/ping1.ps1 | ping1.ps1 |
# ping the ip just once, quickly to see if it is online.
# alternative
# http://ss64.com/ps/syntax-display.html
# Ping the machine to see if it's turned on
#$result = Get-WmiObject -query "select * from win32_pingstatus where address = '$pc'"
filter ping1 {
param (
[Parameter(ValueFromPipeline=... |
PowerShellCorpus/Github/gangstanthony_PowerShell/Get-LogonHistory.ps1 | Get-LogonHistory.ps1 | # https://social.technet.microsoft.com/Forums/office/en-US/4f6815f1-2998-484c-a423-fe6507f1548c/powershell-script-to-fetch-logonlogoff-user-on-particular-server-getwinevent-geteventlog?forum=winserverpowershell
function Get-LogonHistory {
param (
[string]$Computer = $env:COMPUTERNAME,
[int]$Da... |
PowerShellCorpus/Github/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/packages/EntityFramework.6.0.0/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
# MIIarwYJKoZIhvcNAQcCoIIaoDCCGpwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQ... |
PowerShellCorpus/Github/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/packages/EntityFramework.6.0.0/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/packages/EntityFramework.6.1.3/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/sestalin1_Bolsa-de-Empleos/Bolsa de empleos/packages/EntityFramework.6.1.3/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/csharris_psake-pester-test/psake-config.ps1 | psake-config.ps1 | $config.modules=(
"Pester"
)
$config.verboseError=$true
|
PowerShellCorpus/Github/csharris_psake-pester-test/default.tests.ps1 | default.tests.ps1 | Describe "Test" {
It "Tests" {
"True" | Should Be "True"
}
}
|
PowerShellCorpus/Github/csharris_psake-pester-test/default.ps1 | default.ps1 | Task Default -Depends Test
Task Test {
$testResults = Invoke-Pester -Path "$PSScriptRoot\default.tests.ps1" -PassThru
if ($testResults.FailedCount -gt 0) {
$testResults | Format-List
Write-Error -Message 'One or more Pester tests failed. Build cannot continue!'
}
}
|
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Pester.Tests.ps1 | Pester.Tests.ps1 | $here = Split-Path -Parent $MyInvocation.MyCommand.Path
$manifestPath = "$here\Pester.psd1"
$changeLogPath = "$here\CHANGELOG.md"
# DO NOT CHANGE THIS TAG NAME; IT AFFECTS THE CI BUILD.
Describe -Tags 'VersionChecks' "Pester manifest and changelog" {
$script:manifest = $null
It "has a valid manife... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/build.psake.ps1 | build.psake.ps1 | $psake.use_exit_on_error = $true
properties {
$currentDir = resolve-path .
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
$baseDir = $psake.build_script_dir
$version = git.exe describe --abbrev=0 --tags
$nugetExe = "$baseDir\vendor\tools\nuget"
$targetBase = "tools"
}
Task d... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/chocolateyInstall.ps1 | chocolateyInstall.ps1 | [CmdletBinding()]
param ( )
end
{
$modulePath = Join-Path $env:ProgramFiles WindowsPowerShell\Modules
$targetDirectory = Join-Path $modulePath Pester
$scriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
$sourceDirectory = Join-Path $scriptRoot Tools
if ($PSVersionTable... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Examples/Validator/Validator.Tests.ps1 | Validator.Tests.ps1 |
function MyValidator($thing_to_validate) {
return $thing_to_validate.StartsWith("s")
}
function Invoke-SomethingThatUsesMyValidator {
param(
[ValidateScript({MyValidator $_})]
$some_param
)
}
Describe "Testing a validator" {
It "calls MyValidator" {
Mock MyVali... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Examples/Calculator/Add-Numbers.ps1 | Add-Numbers.ps1 | function Add-Numbers($a, $b) {
return $a + $b
}
|
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Examples/Calculator/Add-Numbers.Tests.ps1 | Add-Numbers.Tests.ps1 | $here = Split-Path -Parent $MyInvocation.MyCommand.Path
. "$here\Add-Numbers.ps1"
Describe -Tags "Example" "Add-Numbers" {
It "adds positive numbers" {
Add-Numbers 2 3 | Should Be 5
}
It "adds negative numbers" {
Add-Numbers (-2) (-2) | Should Be (-4)
}
It "adds one ... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Functions/It.Tests.ps1 | It.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe 'Get-PesterResult' {
}
Describe 'It - Implementation' {
$testState = New-PesterState -Path $TestDrive
It 'Throws an error if It is called outside of Describe' {
$scriptBlock = { ItImpl -Pester $testState ... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Functions/TestsRunningInCleanRunspace.Tests.ps1 | TestsRunningInCleanRunspace.Tests.ps1 | function Invoke-PesterInJob ($ScriptBlock, [switch] $GenerateNUnitReport)
{
$PesterPath = Get-Module Pester | Select-Object -First 1 -ExpandProperty Path
$job = Start-Job {
param ($PesterPath, $TestDrive, $ScriptBlock, $GenerateNUnitReport)
Import-Module $PesterPath -Force | Out-Null
... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Functions/TestDrive.ps1 | TestDrive.ps1 | #
function New-TestDrive ([Switch]$PassThru) {
$Path = New-RandomTempDirectory
$DriveName = "TestDrive"
if (-not (& $SafeCommands['Test-Path'] -Path $Path))
{
& $SafeCommands['New-Item'] -ItemType Container -Path $Path | & $SafeCommands['Out-Null']
}
#setup the test drive
... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Functions/BreakAndContinue.Tests.ps1 | BreakAndContinue.Tests.ps1 | Describe 'Clean handling of break and continue' {
# If this test 'fails', it'll just cause most of the rest of the tests to never execute (and we won't see any actual failures.)
# The CI job monitors metrics, though, and will fail the build if the number of tests drops too much.
Context 'Break' {
... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Functions/New-Fixture.ps1 | New-Fixture.ps1 | function New-Fixture {
<#
.SYNOPSIS
This function generates two scripts, one that defines a function
and another one that contains its tests.
.DESCRIPTION
This function generates two scripts, one that defines a function
and another one that contains its tests. The files are by defau... |
PowerShellCorpus/Github/csharris_psake-pester-test/Pester/Functions/TestResults.ps1 | TestResults.ps1 | function Get-HumanTime($Seconds) {
if($Seconds -gt 0.99) {
$time = [math]::Round($Seconds, 2)
$unit = 's'
}
else {
$time = [math]::Floor($Seconds * 1000)
$unit = 'ms'
}
return "$time$unit"
}
function GetFullPath ([string]$Path) {
if (-not [System.IO.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.