full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PowerShellGallery/xScheduledTask/1.0.0.6/DSCResources/xScheduledTask/test.ps1
test.ps1
Configuration Test { Import-DscResource -ModuleName xScheduledTask node localhost { xScheduledTask asd { Name = "A" Path = "\Microsoft\" TaskAction = @( TaskAction { id = 1 Execute = "c:\1.exe" WorkingDirectory = "c:\1...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SecretAudit.ps1
Get-SecretAudit.ps1
Function Get-SecretAudit { <# .SYNOPSIS Get audit trail for a secret from secret server .DESCRIPTION Get audit trail for a secret from secret server .PARAMETER SearchTerm If specified, obtain audit trail for all passwords matching this search term. Accepts wildcards ...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SSFolder.ps1
Get-SSFolder.ps1
Function Get-SSFolder { <# .SYNOPSIS Get details on folders from secret server .DESCRIPTION Get details on folders from secret server .PARAMETER Name Name to search for. Accepts wildcards as '*'. .PARAMETER Id Id to search for. Accepts wildcards as '...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SSTemplateField.ps1
Get-SSTemplateField.ps1
Function Get-SSTemplateField { <# .SYNOPSIS Get fields on secret templates from secret server .DESCRIPTION Get fields on secret templates from secret server .PARAMETER Name Template Name to search for. Accepts wildcards as '*'. .PARAMETER ID Template ...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SecretServerConfig.ps1
Get-SecretServerConfig.ps1
Function Get-SecretServerConfig { <# .SYNOPSIS Get Secret Server module configuration. .DESCRIPTION Get Secret Server module configuration .FUNCTIONALITY Secret Server #> [cmdletbinding()] param( [ValidateSet("Variable","ConfigFile")]$Source = "...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SSUser.ps1
Get-SSUser.ps1
Function Get-SSUser { <# .SYNOPSIS Get secret users from secret server database .DESCRIPTION Get secret users from secret server database This command requires privileges on the Secret Server database. Given the sensitivity of this data, consider exposing this com...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/New-Secret.ps1
New-Secret.ps1
Function New-Secret { <# .SYNOPSIS Create a new secret in secret server .DESCRIPTION Create a new secret in secret server This code only handles a pre-specified set of Secret templates defined in SecretType. Any fields not included in the parameters here are set...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-Secret.ps1
Get-Secret.ps1
Function Get-Secret { <# .SYNOPSIS Get details on secrets from secret server .DESCRIPTION Get details on secrets from secret server. Depending on your configuration, the search will generally include other fields (e.g. Notes). For this reason, we do not strip out ...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Set-Secret.ps1
Set-Secret.ps1
Function Set-Secret { <# .SYNOPSIS Set details on secrets from secret server. .DESCRIPTION Set details on secrets from secret server. If the specified SearchTerm and SearchID find more than a single Secret, we throw an error .PARAMETER SearchTerm String to ...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SecretPermission.ps1
Get-SecretPermission.ps1
Function Get-SecretPermission { <# .SYNOPSIS Get secret permissions from secret server .DESCRIPTION Get secret permissions from secret server. We return one object per access control entry. Some properties are hidden by default, use Select-Object or Get-Member to ...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SecretActivity.ps1
Get-SecretActivity.ps1
Function Get-SecretActivity { <# .SYNOPSIS Get secret activity from secret server database .DESCRIPTION Get secret activity from secret server database This command requires privileges on the Secret Server database. Given the sensitivity of this data, consider exp...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/New-SSConnection.ps1
New-SSConnection.ps1
Function New-SSConnection { <# .SYNOPSIS Create a connection to secret server .DESCRIPTION Create a connection to secret server Default action updates $SecretServerConfig.Proxy which most functions use as a default If you specify a winauthwebservices endpoint, w...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SSFolderPermission.ps1
Get-SSFolderPermission.ps1
Function Get-SSFolderPermission { <# .SYNOPSIS Get secret folder permissions from secret server database .DESCRIPTION Get secret folder permissions from secret server database This command requires privileges on the Secret Server database. Given the sensitivity of...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SSTemplate.ps1
Get-SSTemplate.ps1
Function Get-SSTemplate { <# .SYNOPSIS Get details on secret templates from secret server .DESCRIPTION Get details on secret templates from secret server .PARAMETER Name Name to search for. Accepts wildcards as '*'. .PARAMETER Id Id to search for. Ac...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/New-SSToken.ps1
New-SSToken.ps1
Function New-SSToken { <# .SYNOPSIS Create a token for secret server .DESCRIPTION Create a token for secret server Default action updates $SecretServerConfig.Token .PARAMETER WebServiceProxy Proxy to use. Defaults to $SecretServerConfig.Proxy .PARAM...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Get-SSGroupMembership.ps1
Get-SSGroupMembership.ps1
Function Get-SSGroupMembership { <# .SYNOPSIS Get secret server group membership from database .DESCRIPTION Get secret server group membership from database This command requires privileges on the Secret Server database. Given the sensitivity of this data, conside...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Set-SecretServerConfig.ps1
Set-SecretServerConfig.ps1
Function Set-SecretServerConfig { <# .SYNOPSIS Set Secret Server module configuration. .DESCRIPTION Set Secret Server module configuration, and live $SecretServerConfig global variable. This data is used as the default for most commands. .PARAMETER Proxy Spe...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Private/Invoke-Sqlcmd2.ps1
Invoke-Sqlcmd2.ps1
function Invoke-Sqlcmd2 { <# .SYNOPSIS Runs a T-SQL script. .DESCRIPTION Runs a T-SQL script. Invoke-Sqlcmd2 only returns message output, such as the output of PRINT statements when -verbose parameter is specified. Paramaterized queries are supported. Help d...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Private/Convert-SecStrToStr.ps1
Convert-SecStrToStr.ps1
#Pass in a secure string. For example, $Credential.Password function Convert-SecStrToStr { [cmdletbinding()] param($secstr) Try { $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secstr) [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) }...
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Private/Get-TemplateTable.ps1
Get-TemplateTable.ps1
#Return a hash table of Key=TemplateID Value=TemplateName pairs function Get-TemplateTable { $TemplateTable = @{} Get-SSTemplate | ForEach-Object { $TemplateTable.Add($_.ID, $_.Name) } $TemplateTable }
PowerShellCorpus/PowerShellGallery/SecretServer/1.0/Private/Verify-SecretConnection.ps1
Verify-SecretConnection.ps1
#Return proxy if it is connected. Test with whoami method function Verify-SecretConnection { [cmdletbinding()] param( $Proxy, $Token ) if($Token -notlike "") { $Result = $Proxy.whoami($Token) if(@($Result.Errors).count -gt 0) { t...
PowerShellCorpus/PowerShellGallery/SecureSettings/1.0/Add-SecureSetting.ps1
Add-SecureSetting.ps1
function Add-SecureSetting { <# .Synopsis Adds an encrypted setting to the registry .Description Stores secured user settings in the registry .Example Add-SecureSetting AStringSetting 'A String' .Example Add-SecureSetting AHashtableSetting @{a='b';c='d'} ...
PowerShellCorpus/PowerShellGallery/SecureSettings/1.0/Get-SecureSetting.ps1
Get-SecureSetting.ps1
function Get-SecureSetting { <# .Synopsis Gets encrypted settings stored in the registry .Description Gets secured user settings stored in the registry .Example Get-SecureSetting .Example Get-SecureSetting MySetting .Example Get-SecureSetting M...
PowerShellCorpus/PowerShellGallery/SecureSettings/1.0/Write-PowerShellHashtable.ps1
Write-PowerShellHashtable.ps1
function Write-PowerShellHashtable { <# .Synopsis Takes an creates a script to recreate a hashtable .Description Allows you to take a hashtable and create a hashtable you would embed into a script. Handles nested hashtables and indents nested hashtables automatically....
PowerShellCorpus/PowerShellGallery/SecureSettings/1.0/Remove-SecureSetting.ps1
Remove-SecureSetting.ps1
function Remove-SecureSetting { <# .Synopsis Removes an encrypted setting from the registry .Description Removes a stored secured user settings in the registry .Example Remove-SecureSetting .Example Remove-SecureSetting AStringSetting .Link Ad...
PowerShellCorpus/PowerShellGallery/psexec/0.0.7/Public/Invoke-PsExec.ps1
Invoke-PsExec.ps1
function Invoke-PsExec { [CmdletBinding(DefaultParameterSetName = 'Command')] param( [Parameter(ParameterSetName = 'Command', Mandatory = $true, Position = 0)] [ValidateNotNullOrEmpty()] [String] $Command, [Parameter(ParameterSetNam...
PowerShellCorpus/PowerShellGallery/psexec/0.0.7/Public/Get-PsExec.ps1
Get-PsExec.ps1
function Get-PsExec { [CmdletBinding(ConfirmImpact = 'High', SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true, Position = 0)] [String] $OutPath, [Switch] $Force ) begin { $url = 'https://download.sysin...
PowerShellCorpus/PowerShellGallery/GoogleDynamicDNSTools/3.1/Functions/Update-GoogleDynamicDNS.ps1
Update-GoogleDynamicDNS.ps1
Function Update-GoogleDynamicDNS { <# .SYNOPSIS Sends a HTTPS POST request to the Google domain service to update a dynamic DNS entry .DESCRIPTION This function will send a POST request to the Google domains HTTPS API and set the active IP for a hostname on a given DNS entry. It accomplishes this via a Invoke-W...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Start-Task.ps1
Start-Task.ps1
function Start-Task { <# .Synopsis Starts a scheduled task .Description Starts running a scheduled task. The input to the command is the output of Get-ScheduledTask. .Example New-Task | Add-TaskAction -Script { Get-Process | Out-Gr...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/New-Task.ps1
New-Task.ps1
function New-Task { <# .Synopsis Creates a new task definition. .Description Creates a new task definition. Tasks are not scheduled until Register-ScheduledTask is run. To add triggers use Add-TaskTrigger. To add actions, use Add-TaskActions .Link ...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Add-TaskTrigger.ps1
Add-TaskTrigger.ps1
function Add-TaskTrigger { <# .Synopsis Adds a trigger to an existing task. .Description Adds a trigger to an existing task. The task is outputted to the pipeline, so that additional triggers can be added. .Example New-task | Add-TaskTrigger -DayOfW...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Get-RunningTask.ps1
Get-RunningTask.ps1
function Get-RunningTask { <# .Synopsis Gets the tasks currently running on the system .Description A Detailed Description of what the command does .Example Get-RunningTask #> param( #The name of the task. By default, all running tasks are shown $Name...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Add-TaskAction.ps1
Add-TaskAction.ps1
function Add-TaskAction { <# .Synopsis Adds an action to a task definition .Description Adds an action to a task definition. You can create a task definition with New-Task, or use an existing definition from Get-ScheduledTask .Example New-Task -Disabled | ...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Connect-ToTaskScheduler.ps1
Connect-ToTaskScheduler.ps1
function Connect-ToTaskScheduler { <# .Synopsis Connects to the scheduler service on a computer .Description Connects to the scheduler service on a computer .Example Connect-ToTaskScheduler #> param( # The name of the computer to connect to. $ComputerN...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Get-ScheduledTask.ps1
Get-ScheduledTask.ps1
function Get-ScheduledTask { <# .Synopsis Gets tasks scheduled on the computer .Description Gets scheduled tasks that are registered on a computer .Example Get-ScheduleTask -Recurse #> param( # The name or name pattern of the scheduled task [Parameter(...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Remove-Task.ps1
Remove-Task.ps1
function Remove-Task { <# .Synopsis Removes a scheduled task .Description Removes a scheduled task from the computer. .Example New-Task | Add-TaskAction -Script { Get-Process | Out-GridView Start-Sleep 100 } | ...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Stop-Task.ps1
Stop-Task.ps1
function Stop-Task { <# .Synopsis Stops a scheduled task .Description Stops a scheduled task or a running task. Scheduled tasks can be supplied with Get-Task and .Example # Note, this is an example of the syntax. You should never stop all running tasks, ...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Register-ScheduledTask.ps1
Register-ScheduledTask.ps1
function Register-ScheduledTask { <# .Synopsis Registers a scheduled task. .Description Registers a scheduled task. #> param( # The name of the scheduled task to register [Parameter(Mandatory=$true,Position=0)] [string] $name, # The Scheduled T...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Examples/example6.ps1
example6.ps1
New-Task -Disabled | Add-TaskTrigger $EVT[0] | Add-TaskAction -Path Calc | Register-ScheduledTask "$(Get-Random)"
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Examples/example4.ps1
example4.ps1
New-Task | Add-TaskTrigger -At "3:00 PM" -WeekOfMonth 2,4 ` -DayOfWeek Monday, Wednesday, Friday -MonthOfYear August, April, December | Add-TaskAction -Path calc.exe | Register-ScheduledTask "$(Get-Random)"
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Examples/example5.ps1
example5.ps1
New-Task -MultipleInstancePolicy Parallel | Add-TaskAction -Script { Get-Process | Out-GridView Start-Sleep -Seconds 75 } | Add-TaskTrigger -In (New-TimeSpan -Seconds 15) -Repeat (New-TimeSpan -Minutes 1) -For (New-TimeSpan -Minutes 2) | Register-ScheduledTask -name (Get-Random)...
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Examples/example2.ps1
example2.ps1
New-task | Add-TaskTrigger -at "5:57 PM" | Add-TaskAction -NoExit -Sta -Hidden -Script { Import-Module WPK New-Label "Task Scheduler" -Show } | Register-ScheduledTask "$(Get-Random)"
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Examples/example3.ps1
example3.ps1
New-Task | Add-TaskTrigger -At "3:00 PM" -DayOfMonth 1,2,3,4,5 -MonthOfYear January, April, December | Add-TaskAction -Path calc.exe | Register-ScheduledTask (Get-Random)
PowerShellCorpus/PowerShellGallery/TaskScheduler/1.0/Examples/example1.ps1
example1.ps1
New-task | Add-TaskTrigger -DayOfWeek Monday, Wednesday, Friday -WeeksInterval 2 -At "3:00 PM" | Add-TaskAction -Script { Get-Process | Out-GridView } | Register-ScheduledTask TestTask
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Private/ZabbixJsonObject.ps1
ZabbixJsonObject.ps1
function ZabbixJsonObject { [CmdletBinding()] Param ( [Parameter(Mandatory=$true)] [string]$RequestType, [PSObject]$Parameters ) Write-Verbose -Message "$($MyInvocation.MyCommand.Name): Creating new request object." $RequestObject = New-Object -Type PSObject ...
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Public/Get-ZabbixHost.ps1
Get-ZabbixHost.ps1
function Get-ZabbixHost { <# .SYNOPSIS Gets the hosts from a Zabbix server. .DESCRIPTION The Get-ZabbixHost cmdlet gets the hosts from a Zabbix server. Without parameters, this cmdlet gets all hosts on the server. You can also specify a particular host by host id, group id, ...
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Public/Connect-ZabbixServer.ps1
Connect-ZabbixServer.ps1
function Connect-ZabbixServer { <# .SYNOPSIS Sends a login request to a Zabbix server API service. .DESCRIPTION The Connect-ZabbixServer cmdlet retreives the Api authentication key for the session using the credentials provided. .PARAMETER Server Specifies the name of the ...
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Public/Get-ZabbixHostGroup.ps1
Get-ZabbixHostGroup.ps1
function Get-ZabbixHostGroup { <# .SYNOPSIS Gets the host groups from a Zabbix server. .DESCRIPTION The Get-ZabbixHostGroup cmdlet gets the host groups from a Zabbix server. Without parameters, this cmdlet gets all host groups on the server. You can also specify a particular...
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Public/Get-ZabbixItem.ps1
Get-ZabbixItem.ps1
function Get-ZabbixItem { <# .SYNOPSIS Gets the items from a Zabbix server. .DESCRIPTION The Get-ZabbixItem cmdlet gets the items from a Zabbix server. Without parameters, this cmdlet gets all items on the server. You can also specify a particular item[s] by item id, host id...
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Public/Get-ZabbixTemplate.ps1
Get-ZabbixTemplate.ps1
function Get-ZabbixTemplate { <# .SYNOPSIS Gets the hosts from a Zabbix server. .DESCRIPTION The Get-ZabbixHost cmdlet gets the hosts from a Zabbix server. Without parameters, this cmdlet gets all hosts on the server. You can also specify a particular host by host id, group ...
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Public/Get-ZabbixItemHistory.ps1
Get-ZabbixItemHistory.ps1
function Get-ZabbixItemHistory { <# .SYNOPSIS Gets the item history from a Zabbix server. .DESCRIPTION The Get-ZabbixItemHistory cmdlet gets the item history from a Zabbix server. Without parameters, this cmdlet gets all items on the server. You can also specify a particular...
PowerShellCorpus/PowerShellGallery/PoshZabbixTools/0.1.5/Public/Disconnect-ZabbixServer.ps1
Disconnect-ZabbixServer.ps1
function Disconnect-ZabbixServer { <# .SYNOPSIS Sends a logout request to a Zabbix server API service. .DESCRIPTION The Disconnect-ZabbixServer function sends a logout request to the Zabbix server API and removes the local session information. .EXAMPLE Disconnect-ZabbixSer...
PowerShellCorpus/PowerShellGallery/QrCodes/1.0.0.48/ExportedFunctions/Format-QRCode.ps1
Format-QRCode.ps1
<# .SYNOPSIS Takes a QRCode object and formats it for output on the screen. .DESCRIPTION Uses line drawing to convert a QRCode for display on the screen. .PARAMETER QRCode A QRCode output from ConvertTo-QRCode .PARAMETER TopPadding The ammount of padding to put around the code. .PARAMETER SidePaddin...
PowerShellCorpus/PowerShellGallery/QrCodes/1.0.0.48/ExportedFunctions/New-VCard.ps1
New-VCard.ps1
<# .SYNOPSIS Builds a VCard .DESCRIPTION Uses the data passed in as parameters to build a valid VCard string. .PARAMETER Name The name to be put in the "N" VCard field. .PARAMETER FormattedName The name to be put in the "FN" VCard field. .PARAMETER Nickname The name to be put in the "NICKNAM...
PowerShellCorpus/PowerShellGallery/QrCodes/1.0.0.48/ExportedFunctions/Out-BarcodeImage.ps1
Out-BarcodeImage.ps1
<# .SYNOPSIS Creates a barcode and saves it as an image file. .DESCRIPTION Uses the ZXing.Net library to create barcodes and save them as image files. .PARAMETER Content The contents of the barcode. This needs to be valid content for the BarcodeFormat you are writing. .PARAMETER BarcodeFormat One of...
PowerShellCorpus/PowerShellGallery/QrCodes/1.0.0.48/ExportedFunctions/ConvertTo-QRCode.ps1
ConvertTo-QRCode.ps1
<# .SYNOPSIS Converts input to a QRCode object. .DESCRIPTION Uses the ZXing.Net library to convert input to a QRCode object. .PARAMETER InputObject The data to encode into a QRCode .PARAMETER ErrorCorrection The ammount of redundant data to include in the QRCode for error correction. .EXAMPLE Co...
PowerShellCorpus/PowerShellGallery/OVF.Windows.Server/1.0.2/Diagnostics/Simple/Services.tests.ps1
Services.tests.ps1
#require -modules poshspec Import-Module -Name poshspec -Verbose:$false -ErrorAction Stop describe 'Operating System' { context 'Availability' { service DHCP status { should be running } service DNSCache status { should be running } service Eventlog status { should be running } ...
PowerShellCorpus/PowerShellGallery/OVF.Windows.Server/1.0.2/Diagnostics/Simple/Network.tests.ps1
Network.tests.ps1
#require -modules poshspec param( [string[]]$Interfaces = (Get-NetAdapter -Physical).Name ) Import-Module -Name poshspec -Verbose:$false -ErrorAction Stop describe 'Network Adapters' { context 'Availability' { $adapters = Get-NetAdapter -Name $Interfaces -Physical $adapters | % { ...
PowerShellCorpus/PowerShellGallery/OVF.Windows.Server/1.0.2/Diagnostics/Simple/Memory.tests.ps1
Memory.tests.ps1
#require -modules poshspec param( $FreeRamMbytesThreshold = 500, $FreeSystemPageTableEntriesThreshold = 5000 ) Import-Module -Name poshspec -Verbose:$false -ErrorAction Stop describe 'Memory' { context 'Capacity' { it "MB Free should be greater than $FreeRamMbytesThreshold" { ...
PowerShellCorpus/PowerShellGallery/OVF.Windows.Server/1.0.2/Diagnostics/Simple/LogicalDisk.tests.ps1
LogicalDisk.tests.ps1
#require -modules poshspec param( $FreeSystemDriveMBytesThreshold = 500, $FreeSystemDrivePctThreshold = .05, $FreeNonSystemDriveMBytesThreshold = 1000, $FreeNonSystemDrivePctThreshold = .05 ) Import-Module -Name poshspec -Verbose:$false -ErrorAction Stop describe 'Logical Disks' { $...
PowerShellCorpus/PowerShellGallery/PSCommonSql/1.0.21/Invoke-SqlQuery.ps1
Invoke-SqlQuery.ps1
function Invoke-SqlQuery { <# .SYNOPSIS Runs a SQL script against a SQLite database. .DESCRIPTION Runs a SQL script against a SQLite database. Paramaterized queries are supported. Help details below borrowed from Invoke-Sqlcmd, may be inaccurate here. .PARAMETER...
PowerShellCorpus/PowerShellGallery/PSCommonSql/1.0.21/Register-DbProvider.ps1
Register-DbProvider.ps1
function Register-DbProvider { param( $DbProviderFactory ) if(-not $Script:DbProviderFactories) { $Script:DbProviderFactories = @{} } $Script:DbProviderFactories[$DbProviderFactory.Invariant] = $DbProviderFactory }
PowerShellCorpus/PowerShellGallery/PSCommonSql/1.0.21/Get-DbProviderFactory.ps1
Get-DbProviderFactory.ps1
function Get-DbProviderFactory { [CmdletBinding()] [OutputType([System.Data.Common.DbProviderFactory])] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $DbProviderName ) if($Script:DbProviderFactories) { $FactoryDefinition = $Script:DbProviderFactories[$DbProviderName] } else ...
PowerShellCorpus/PowerShellGallery/PSCommonSql/1.0.21/New-SqlConnection.ps1
New-SqlConnection.ps1
function New-SqlConnection { <# .SYNOPSIS Creates a SQLiteConnection to a SQLite data source .DESCRIPTION Creates a SQLiteConnection to a SQLite data source .PARAMETER DataSource SQLite Data Source to connect to. .PARAMETER Password Specifies A Secure St...
PowerShellCorpus/PowerShellGallery/PSCommonSql/1.0.21/Out-DataTable.ps1
Out-DataTable.ps1
function Out-DataTable { <# .SYNOPSIS Creates a DataTable for an object .DESCRIPTION Creates a DataTable based on an object's properties. .PARAMETER InputObject One or more objects to convert into a DataTable .PARAMETER NonNullable A list of columns to set disable AllowDBNull on .INPUTS Object ...
PowerShellCorpus/PowerShellGallery/PSCommonSql/1.0.21/Invoke-SqlBulkCopy.ps1
Invoke-SqlBulkCopy.ps1
function Invoke-SQLBulkCopy { <# .SYNOPSIS Use a SQLite transaction to quickly insert data .DESCRIPTION Use a SQLite transaction to quickly insert data. If we run into any errors, we roll back the transaction. The data source is not limited to SQL Server; any data source can be used, as long as the d...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/ProxyFunction.Process.Pipeline.ps1
ProxyFunction.Process.Pipeline.ps1
<# .SYNOPSIS Proxy function process block .DESCRIPTION The process block of a proxy function. #> [System.Diagnostics.DebuggerHidden()] param() try { #region Process the element that was just received from the previous stage in the pipeline. $pipeline.Process($_) #endregion } catch { ...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/Module.NewAlias.Export.ps1
Module.NewAlias.Export.ps1
<# .SYNOPSIS Create a new alias and export it from the module .DESCRIPTION Create a new alias that is associated with a cmdlet or function and export the alias from the module in which it is created. If the alias is optional and provided for convenience only, no error will be raised if the alias cannot be c...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/ScriptFile.Import.ps1
ScriptFile.Import.ps1
<# .SYNOPSIS Import script files .DESCRIPTION Import one or more script files into the current scope. #> [System.Diagnostics.DebuggerHidden()] param( # The path where the script files are located. [System.String] $Path, # A filter to select which script files should be imported. ...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/Module.NewAlias.NoExport.ps1
Module.NewAlias.NoExport.ps1
<# .SYNOPSIS Create a new alias that is internal to a module .DESCRIPTION Create a new internal alias that is associated with a cmdlet or function. This alias is not exported by the module in which it is created. If the alias is optional and provided for convenience only, no error will be raised if the alia...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/ProxyFunction.Process.NoPipeline.ps1
ProxyFunction.Process.NoPipeline.ps1
<# .SYNOPSIS Proxy function process block (no pipeline input) .DESCRIPTION The process block of a proxy function that does not accept pipeline input. #> [System.Diagnostics.DebuggerHidden()] param() try { #region Invoke the process block without sending in pipeline input. $pipeline.Process()...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/ProxyFunction.Begin.ps1
ProxyFunction.Begin.ps1
<# .SYNOPSIS Proxy function begin block .DESCRIPTION The begin block of a proxy function. #> [System.Diagnostics.DebuggerStepThrough()] param( # The name of the command being proxied. [System.String] $CommandName, # The type of the command being proxied. Valid values include 'Cmdlet...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/ProxyFunction.End.ps1
ProxyFunction.End.ps1
<# .SYNOPSIS Proxy function end block .DESCRIPTION The end block of a proxy function. #> [System.Diagnostics.DebuggerHidden()] param() try { #region Close the pipeline. $pipeline.End() #endregion } catch { $PSCmdlet.ThrowTerminatingError($_) } # SIG # Begin signature block # ...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/ScriptFile.Import.Ordered.ps1
ScriptFile.Import.Ordered.ps1
<# .SYNOPSIS Import script files (ordered) .DESCRIPTION Import one or more script files in a specific order into the current scope. #> [System.Diagnostics.DebuggerHidden()] param( # The path where the script files are located. [System.String] $Path, # The order in which you want the...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/Module.Initialize.ps1
Module.Initialize.ps1
<# .SYNOPSIS Initialize script module .DESCRIPTION Initialize a script module with strict mode, explicit export, and variables that should be set by default. #> [System.Diagnostics.DebuggerHidden()] param( # The strict mode version that will be applied to the module. [System.String] $Stric...
PowerShellCorpus/PowerShellGallery/SnippetPx/1.0.5.18/snippets/ProxyFunction.DynamicParameters.ps1
ProxyFunction.DynamicParameters.ps1
<# .SYNOPSIS Proxy function dynamic parameter block .DESCRIPTION The dynamic parameter block of a proxy function. This block can be used to copy a proxy function target's parameters, regardless of changes from version to version. #> [System.Diagnostics.DebuggerStepThrough()] param( # The name of the...
PowerShellCorpus/PowerShellGallery/SpiceWorld2016_PowerShellUnplugged/1.0.0/Show-Object1.ps1
Show-Object1.ps1
#[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") #[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") add-type -AssemblyName System.Windows.Forms -Verbose add-type -AssemblyName System.Drawing -verbose [void][System.Reflection.Assembly]::LoadWithPartialName("S...
PowerShellCorpus/PowerShellGallery/SpiceWorld2016_PowerShellUnplugged/1.0.0/SpiceWorld2016_PowerShellUnplugged.ps1
SpiceWorld2016_PowerShellUnplugged.ps1
#region Step 1 The Challenge # someone said it was easy to use BASH to get info from Github # curl https://api.github.com/repos/PowerShell/PowerShell/releases| grep download_count releases | awk '{ print $2 }' | sed 's/,//' # I first tried this using Invoke-WebRequest. I hacked it up to find info Gal Curl $...
PowerShellCorpus/PowerShellGallery/SitecoreShipFunctions/1.2.3/Install.ps1
Install.ps1
# Adapted from posh-git's install.ps1 # Copyright (c) 2010-2011 Keith Dahlby and contributors param( [switch]$WhatIf = $false, [string] $WhichProfile = $PROFILE.CurrentUserCurrentHost ) if($PSVersionTable.PSVersion.Major -lt 3) { Write-Warning "SitecoreShipFunctions requires PowerShell 3.0 or better; you have v...
PowerShellCorpus/PowerShellGallery/SitecoreShipFunctions/1.2.3/Chocolatey/tools/chocolateyInstall.ps1
chocolateyInstall.ps1
$name = "SitecoreShipFunctions" $url = "https://github.com/patrickperrone/Sitecore.Ship-PowerShell-Functions/archive/v1.1.0.zip" $unzipLocation = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" Install-ChocolateyZipPackage $name $url $unzipLocation $installer = Join-Path $unziplocation 'Sitecore.Ship-Power...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/tests.ps1
tests.ps1
Import-Module Pester $script:moduleRoot = Split-Path -Path $MyInvocation.MyCommand.Path $script:debugMode = $true # Dot source functions "$script:moduleRoot\functions\*.ps1" | Resolve-Path | %{. $_.ProviderPath} Invoke-Pester tests
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/tests/TestSetup.ps1
TestSetup.ps1
$script:configFileName = 'dirtags.json' $script:configFilePath = ('TestDrive:\' + $script:configFileName) $script:tagVariables = @() $script:missingConfigMessageCount = 0 function Setup-TestData() { $config = @' { "dirTags": [ { "name": "serverdocs", "path": "docs\\internal\\server...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/tests/Config.Tests.ps1
Config.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $moduleRoot = "$here\.." "$moduleRoot\functions\*.ps1" | Resolve-Path | %{. $_.ProviderPath; write-host $_.ProviderPath} . "$here\TestSetup.ps1" Describe "GetDirTagsConfig" { Setup-TestData $result = GetDirTagsConfig It "doesn't throw" {...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/UnregisterDirTags.ps1
UnregisterDirTags.ps1
<# Clean up any variables that were created as dirtags #> function UnregisterDirTags() { foreach($var in $script:tagVariables) { if ($script:debugMode) {write-host ('removing variable ${0}' -f $var.name)} if (Get-Variable $var.name -scope global -ErrorAction SilentlyContinue) { ...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/RegisterWorkspaceTags.ps1
RegisterWorkspaceTags.ps1
function RegisterWorkspaceTags { foreach($wt in GetWorkspaceTagsConfig) { if ($script:debugMode) {write-host ('creating workspace ${0} to {1}' -f $wt.name, $wt.path)} New-Variable $wt.name -Value $wt.path -Scope 'global' -Force $script:tagVariables += @{name = $wt.name; path = $wt.path...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/Setup.ps1
Setup.ps1
function Unregister-DirTagsPrompt { [CmdletBinding()] param ([switch]$debugMode) PROCESS { UnregisterDirTags if ($global:prompt_old -ne $null) { write-host 'Restoring old prompt...' set-content function:\global:prompt $global:prompt_old } ...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/RegisterDirTags.ps1
RegisterDirTags.ps1
function RegisterDirTags { foreach($dt in GetCurrentDirTags) { if ($script:debugMode) {write-host ('setting ${0} to {1}' -f $dt.name, $dt.path)} New-Variable $dt.name -Value $dt.path -Scope 'global' -Force $script:tagVariables += @{name = $dt.name; path = $dt.path} } }
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/GetCurrentDirTags.ps1
GetCurrentDirTags.ps1
<# Returns Dirtags that exist based on current directory #> function GetCurrentDirTags() { $result = @() foreach($dt in GetDirTagsConfig) { $curPath = $pwd $foundPath = $null # Move up the directory tree until a match is found or root is reached. while ($foundPat...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/GetWorkspaceDirTags.ps1
GetWorkspaceDirTags.ps1
<# Returns dirtags that exist in each workspace. Example: $workspace1_sometag #> function GetWorkspaceDirTags() { $result = @() foreach($wt in GetWorkspaceTagsConfig) { foreach($dt in GetDirTagsConfig) { if (test-path (join-path $wt.path $dt.path)) { $tagName = ('{0}...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/HandleHelpMessage.ps1
HandleHelpMessage.ps1
<# Output a helpfull message if appropriate #> function HandleHelpMessage() { if ($script:missingConfigMessageCount -eq 0) { if (!(Test-Path $script:configFilePath)) { Import-LocalizedData -basedirectory $script:moduleRoot -filename 'PSDirTag.psd1' -bindingvariable manife...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/Get-DirTags.ps1
Get-DirTags.ps1
<# Formatted output of currently set dirtags. #> function Get-DirTags { [CmdletBinding()] param () PROCESS { $result = @() foreach ($dt in $script:tagVariables) { $result += (@{name = '$' + $dt.name; path = $dt.path}) } $result | %{ ...
PowerShellCorpus/PowerShellGallery/PSDirTag/1.0.7/functions/Settings.ps1
Settings.ps1
function GetDirTagsConfig { $result = @() if (test-path $script:configFilePath) { $tags = (get-content $script:configFilePath -Raw) | ConvertFrom-Json $result = $tags.dirTags } return $result } function GetWorkspaceTagsConfig { $result = @() if (test-path $script:...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/working-with-sql-server/snippets.ps1
snippets.ps1
# create a connection ```PowerShell $conn = New-Object -Type System.Data.SqlClient.SqlConnection $conn.ConnectionString = 'Server=SQL1;Database=MyDB;Trusted_Connection=True;' $conn.Open() ``` # INSERT model INSERT INTO <tablename> (Column1, Column2, Column3) VALUES (Value1, Value2, Value3) # INSERT example ...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/working-with-xml/snippets.ps1
snippets.ps1
# exporting drive information get-ciminstance win32_logicaldisk -filter "drivetype=3" | export-clixml .\ disks.xml # import the file $d = import-clixml .\disks.xml # importing native XML [xml]$data = Get-content .\BandData.xml # manipulate the data $data.bands.band | Select @{Name="Name";Expression = {$_.name...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/working-with-xml/HotfixInventory.ps1
HotfixInventory.ps1
#get hotfix data $data = Get-Hotfix -ComputerName $env:computername | Select Caption,InstalledOn,InstalledBy,HotfixID,Description #create a name mapping hashtable $map = [ordered]@{ 'update-id' = 'HotFixID' 'update-type' = 'Description' 'install-date' = 'InstalledOn' 'install-by' = 'InstalledBy' ...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/working-with-xml/DiskReportingXML.ps1
DiskReportingXML.ps1
#requires -version 5.0 Function Get-DiskUsage { [cmdletbinding()] Param( [Parameter(Position = 0,ValueFromPipeline)] [string[]]$Computername = $env:Computername) Begin { #define a hashtable of parameter values for Get-CimInstance $pm = @{ Classname = 'Win32_logicaldisk' Filter = "drivetype=3" ...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/unit-testing-your-code/snippets.ps1
snippets.ps1
# to run the demos, you'll need to copy and paste each bit into the correct location. # or, use the StepX sample code folders and invoke Pester from there # simple function to test function Get-FileContents { [CmdletBinding()] Param( [Parameter(Mandatory=$True, ValueFromPipeline=$Tru...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/unit-testing-your-code/step4/Get-FileContents.Tests.ps1
Get-FileContents.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' . "$here\$sut" Describe "Get-FileContents" { MkDir TESTDRIVE:\Part1 MkDir TESTDRIVE:\Part1\Part2 MkDir TESTDRIVE:\Part1\Part3 "sample" | Out-File TESTDRIVE:...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/unit-testing-your-code/step4/Get-FileContents.ps1
Get-FileContents.ps1
function Get-FileContents { [CmdletBinding()] Param( [Parameter(Mandatory=$True, ValueFromPipeline=$True)] [string[]]$Path ) PROCESS { foreach ($folder in $path) { Write-Verbose "Path is $folder" $folder = $folder -replace "/...
PowerShellCorpus/PowerShellGallery/PowerShell-Toolmaking/1.0.0.19/Chapters/unit-testing-your-code/step3/Get-FileContents.Tests.ps1
Get-FileContents.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' . "$here\$sut" Describe "Get-FileContents" { MkDir TESTDRIVE:\Part1 MkDir TESTDRIVE:\Part1\Part2 MkDir TESTDRIVE:\Part1\Part3 "sample" | Out-File TESTDRIVE:...