full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Private/Get-UnixTimestamp.ps1
Get-UnixTimestamp.ps1
function Get-UnixTimestamp ([DateTime]$Date = (get-date)) { [int][double]::Parse((Get-Date $Date -UFormat %s)) }
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Private/Get-WMIBMCIPAddress.ps1
Get-WMIBMCIPAddress.ps1
function Get-WMIBMCIPAddress { <# .SYNOPSIS Accesses WMI to obtain the BMC IP Address of the device .NOTES Based on script by Michael Albert (http://michlstechblog.info/blog/windows-read-the-ip-address-of-a-bmc-board/) .PARAMETER ComputerName Name of the Windows Computer to check for a BMC #> param ( [Parameter(Man...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Private/Convert-TraverseStatus.ps1
Convert-TraverseStatus.ps1
<# .Synopsis Takes either a traverse status integer or string and converts it back-and-forth. #> function Convert-TraverseStatus { [CmdletBinding(DefaultParameterSetName="StringToInt")] param ( [Parameter(Mandatory,ParameterSetName="IntToString")][Int]$StatusNumber, [Parameter(Mandatory,Paramet...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Private/Get-WMICustom.ps1
Get-WMICustom.ps1
########################################### # Function Get-WmiCustom([string]$computername,[string]$namespace,[string]$class,[int]$timeout=15) # by Daniele Muscetta, MSFT # originally published at http://www.muscetta.com/2009/05/27/get-wmicustom/ # # works as a replacement for the Get-WmiObject cmdlet, # but includes a...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Private/ConvertFrom-UnixTimestamp.ps1
ConvertFrom-UnixTimestamp.ps1
function ConvertFrom-UnixTimestamp{ param ( [int]$UnixTimestamp=0, #Specify if the timestamp was collected in a different timezone [int]$SourceTimeZone=0, #Specify if the timestamp is UTC (Skip UTC Conversion) [switch]$UTC ) [datetime]$origin = '1970-01-01 00:00:00' ...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Private/Convert-HashTableToXML.ps1
Convert-HashTableToXML.ps1
function Convert-HashTableToXML() { <# .SYNOPSIS COnverts one or more Powershell hashtables into a simple XML format. .DESCRIPTION Creates simpler and more human-readable output for a hashtable than Export-CliXML or ConvertTo-XML. This is useful for instance when storing attributes or configuration variables for outpu...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseDeviceExtendedInfo.ps1
Get-TraverseDeviceExtendedInfo.ps1
function Get-TraverseDeviceExtendedInfo { <# .SYNOPSIS Gets the extended properties store in a device tag and converts them back to usable XML format. .PARAMETER Tag The number of the tag where extended properties are stored. Defaults to 5 .PARAMETER Credential Alternate Credentials to use for connection .NOTES Curr...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Update-TraverseWindowsExtendedInfo.ps1
Update-TraverseWindowsExtendedInfo.ps1
function Update-TraverseWindowsExtendedInfo { <# .SYNOPSIS Queries Customer Windows Servers and updates their Traverse Extended Info (stored in Tag5) .PARAM TraverseAccountName Name of the customer account to update. The computer system must have network access to the systems to be updated. Must match exactly for saf...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseLegacyDevice.ps1
Get-TraverseLegacyDevice.ps1
function Get-TraverseLegacyDevice { <# .SYNOPSIS Gets Traverse Devices using the legacy API which supports some different properties .Notes TODO: Search Criteria #> [CmdletBinding()] param ( [PSCredential]$Credential=$TraverseLegacyCredential ) if (!$TraverseLegacyCredential) {write-warning "Y...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Set-TraverseDevice.ps1
Set-TraverseDevice.ps1
function Set-TraverseDevice { <# .SYNOPSIS Update the configuration of a device. Currently this only supports some basic descriptive information. .NOTES This is a wrapper around the Device.Update FlexAPI command http://help.kaseya.com/webhelp/EN/tv/7000000/dev/index.asp#30181.htm Supports Common Parameters -Whatif and...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Invoke-TraverseCommand.ps1
Invoke-TraverseCommand.ps1
function Invoke-TraverseCommand { <# .SYNOPSIS Executes a command using either the Traverse JSON or REST Interfaces .DESCRIPTION This cmdlet executes a Traverse API command and formats the result as a Powershell Custom Object This cmdlet mostly serves as a wrapper around the APIs to make them easier to use. Most of th...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseTestGraph.ps1
Get-TraverseTestGraph.ps1
function Get-TraverseTestGraph { <# .SYNOPSIS Retrieves a historical data graph for a given Traverse test. Test information may be specified either directly with the serial number, or by passing a test object via the pipeline. .EXAMPLE Get-TraverseTestGraph -TestSerial 15089601 -start (get-date).addmonths(-6) Gets th...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseContainer.ps1
Get-TraverseContainer.ps1
function Get-TraverseContainer { <# .SYNOPSIS Retrieves Traverse Container Objects .DESCRIPTION .NOTES .EXAMPLE #> [CmdletBinding()] param ( ) # Param #region Main process { $TraverseCommandParams = @{ API="REST" Verbose=($PSBoundParameters['Verbose'] -eq $true) ArgumentList=@{} } ...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Remove-TraverseDevice.ps1
Remove-TraverseDevice.ps1
function Remove-TraverseDevice { <# .SYNOPSIS Deletes a Traverse Device .PARAM DeviceName Name of the Device. May use Regex to select multiple devices #> [CmdletBinding(SupportsShouldProcess,ConfirmImpact="High")] param( [Alias("Name","DeviceName")][Parameter (Mandatory,Value...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Connect-TraverseBVE.ps1
Connect-TraverseBVE.ps1
function Connect-TraverseBVE { <# .SYNOPSIS Connects to a Traverse BVE system in order to execute commands on the system. .NOTES You should only use Connect-TraverseBVE once per powershell session. #> param ( #The DNS name or IP address of the Traverse BVE system [Parameter(Mandatory=$true)][String]$Hostnam...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseTestStatus.ps1
Get-TraverseTestStatus.ps1
function Get-TraverseTestStatus { <# .SYNOPSIS Retrieves Traverse Test status based on specified criteria. .DESCRIPTION This command leverages the Traverse APIs to get the current status of a device. #> [CmdletBinding(DefaultParameterSetName="deviceName")] param ( [Parameter(ParameterSetName="deviceN...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseDGE.ps1
Get-TraverseDGE.ps1
function Get-TraverseDGE { <# .SYNOPSIS Retrieves Traverse DGE Objects .DESCRIPTION .NOTES .EXAMPLE #> [CmdletBinding()] param ( ) # Param #region Main process { $TraverseCommandParams = @{ API="REST" Verbose=($PSBoundParameters['Verbose'] -eq $true) ArgumentList=@{} } (Invoke...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseTestRawHistoricalData.ps1
Get-TraverseTestRawHistoricalData.ps1
function Get-TraverseTestRawHistoricalData { <# .SYNOPSIS Retrieves historical data for a given Traverse test. Test information may be specified either directly with the serial number, or by passing a test object via the pipeline. .NOTES The amount of results depends on your timescale. You may receive less total res...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseMonitorConfig.ps1
Get-TraverseMonitorConfig.ps1
function Get-TraverseMonitorConfig { <# .SYNOPSIS Retrieves the shared monitor configurations (including credentials) .DESCRIPTION This command obtains all the shared monitor credentials used in tests. It can be used to retrieve ` the information about a shared configuration. .NOTES While this command retrieves the c...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseWindowsServerExtendedInfo.ps1
Get-TraverseWindowsServerExtendedInfo.ps1
workflow Get-TraverseWindowsServerExtendedInfo { <# .SYNOPSIS Gets extended information about a Traverse Windows Device such as BMC and Serial Number, and adds an ExtendedInfo property to the device object .PARAMETER TraverseDeviceObject One or more Traverse Device Objects obtained via Get-TraverseDevice .PARAMETER T...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseDevice.ps1
Get-TraverseDevice.ps1
function Get-TraverseDevice { <# .SYNOPSIS Retrieves Traverse Devices based on specified criteria. .DESCRIPTION This command leverages the Traverse APIs to gather information about devices in Traverse. It retrieves all devices visible to the user by default if no parameters are specified. .PARAMETER Filter A Standard...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseDepartment.ps1
Get-TraverseDepartment.ps1
function Get-TraverseDepartment { <# .SYNOPSIS Retrieves Traverse Department Objects .DESCRIPTION .NOTES .EXAMPLE #> [CmdletBinding()] param ( ) # Param #region Main process { $TraverseCommandParams = @{ API="REST" Verbose=($PSBoundParameters['Verbose'] -eq $true) ArgumentList=@{} ...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/Get-TraverseTest.ps1
Get-TraverseTest.ps1
function Get-TraverseTest { <# .SYNOPSIS Retrieves Traverse Tests based on specified criteria. .DESCRIPTION This command leverages the Traverse APIs to gather information about tests in Traverse. .EXMPLE Get-TraverseTest Device1 Gets all tests from device Device1 .EXAMPLE Get-TraverseTest -TestName '*disk*' -DeviceN...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Public/New-TraverseDevice.ps1
New-TraverseDevice.ps1
function New-TraverseDevice { <# .SYNOPSIS Creates a new Traverse Device using the REST API .NOTES No Web Services API was present to create a device that I could find as of version 8.0 .PARAM DeviceName Name of the device as displayed in the console. The DNS name for this device will auto...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/CI/AppVeyorDeploy.ps1
AppVeyorDeploy.ps1
#Powershell Module Deployment Script #Skip deployment if this is not a master branch commit and a version tag is not detected if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notmatch 'master') { write-host -ForegroundColor yellow "DEPLOY PHASE: Not master branch, skipping" exit } elseif ($env:APPV...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/CI/psake.ps1
psake.ps1
# PSake makes variables declared here available in other scriptblocks # Init some things Properties { # Find the build folder based on build system $ProjectRoot = $ENV:BHProjectPath if(-not $ProjectRoot) { $ProjectRoot = $PSScriptRoot } $Timestamp = Get-date -uformat...
PowerShellCorpus/PowerShellGallery/Traverse/0.6.2/Tests/Traverse.Tests.ps1
Traverse.Tests.ps1
$Verbose = @{} if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master") { $Verbose.add("Verbose",$True) } $PSVersion = $PSVersionTable.PSVersion.Major Import-Module $PSScriptRoot\..\Traverse -Force #Integration test example Describe "Traverse PS$PSVersion Basic Command Testing" { Context...
PowerShellCorpus/PowerShellGallery/SqlServer/21.0.17099/SqlServerPostScript.ps1
SqlServerPostScript.ps1
# Define function function SQLSERVER: { Set-Location SQLSERVER: } # Define aliases for backward compatibility Set-Alias -Name Encode-SqlName -Value ConvertTo-EncodedSqlName Set-Alias -Name Decode-SqlName -Value ConvertFrom-EncodedSqlName # SIG # Begin signature block # MIIkKAYJKoZIhvcNAQcCoIIkGTCCJBUCAQExDzA...
PowerShellCorpus/PowerShellGallery/SqlServer/21.0.17099/SqlServer.ps1
SqlServer.ps1
Set-Variable -scope Global -name SqlServerMaximumChildItems -Value 0 Set-Variable -scope Global -name SqlServerConnectionTimeout -Value 30 Set-Variable -scope Global -name SqlServerIncludeSystemObjects -Value $false Set-Variable -scope Global -name SqlServerMaximumTabCompletion -Value 1000 # Load misc assemblies ...
PowerShellCorpus/PowerShellGallery/xSCSPF/1.3.1.0/Examples/SCSPF-MultiInstance.ps1
SCSPF-MultiInstance.ps1
#requires -Version 5 Configuration SPF { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM Import-DscResource -Module xSCSPF # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($A...
PowerShellCorpus/PowerShellGallery/xSCSPF/1.3.1.0/Examples/SCSPF-SeperateSQL.ps1
SCSPF-SeperateSQL.ps1
#requires -Version 5 Configuration SPF { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM Import-DscResource -Module xSCSPF # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($A...
PowerShellCorpus/PowerShellGallery/xSCSPF/1.3.1.0/Examples/SCSPF-MultiInstance-TP.ps1
SCSPF-MultiInstance-TP.ps1
#requires -Version 5 Configuration SPF { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM Import-DscResource -Module xSCSPF # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($A...
PowerShellCorpus/PowerShellGallery/xSCSPF/1.3.1.0/Examples/SCSPF-SeperateSQL-TP.ps1
SCSPF-SeperateSQL-TP.ps1
#requires -Version 5 Configuration SPF { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM Import-DscResource -Module xSCSPF # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($A...
PowerShellCorpus/PowerShellGallery/xSCSPF/1.3.1.0/Examples/SCSPF-SingleServer-TP.ps1
SCSPF-SingleServer-TP.ps1
#requires -Version 5 Configuration SPF { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM Import-DscResource -Module xSCSPF # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($A...
PowerShellCorpus/PowerShellGallery/xSCSPF/1.3.1.0/Examples/SCSPF-SingleServer.ps1
SCSPF-SingleServer.ps1
#requires -Version 5 Configuration SPF { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM Import-DscResource -Module xSCSPF # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($A...
PowerShellCorpus/PowerShellGallery/SevOne/1.0.13/tests/SevOne.Tests.ps1
SevOne.Tests.ps1
Import-Module ..\SevOne.psd1 <# Describe 'Testing the SevOne Module' { Context 'Looking at Devices' { It 'Returns at least 1 device' { (Get-SevOneDevice | Measure-Object).count -ge 1 | Should be $true } } Context 'Looking at Objects' { It 'Returns at least one object' { (Ge...
PowerShellCorpus/PowerShellGallery/SevOne/1.0.13/RESTful/scratch.ps1
scratch.ps1
$Header = @{} $APIKey = '' function getAuthToken { param ( [string]$ComputerName, [pscredential]$Credential ) $Body = @{ 'name' = $Credential.UserName 'password' = $Credential.GetNetworkCredential().Password } | convertto-json $Auth = Invoke-RestMethod -Uri http://$ComputerName/api/v1/authent...
PowerShellCorpus/PowerShellGallery/SevOne/1.0.13/classes/classes.ps1
classes.ps1
enum plugins { COC CALLMANAGER CALLMANAGERCDR DEFERRED DNS HTTP ICMP IPSLA JMX MYSQLDB NBAR ORACLEDB PORTSHAKER PROCESS PROXYPING SNMP CALLD VMWARE WEBSTATUS WMI BULKDATA } enum timezone { } class SevOne { } class device : SevOne { #Properties [int]$id [string]$na...
PowerShellCorpus/PowerShellGallery/SevOne/1.0.13/scripts/Alerts.ps1
Alerts.ps1
PowerShellCorpus/PowerShellGallery/MyAlbum/0.1.2/Test/MyAlbum.Tests.ps1
MyAlbum.Tests.ps1
$DestiantionPath = "$env:tmp\MyAlbumTests\InstallPackage" $SavePath = "$env:tmp\MyAlbumTests\ForSavePackage" Describe "MyAlblum Test Cases" -Tags @('BVT', 'DRT') { BeforeAll { # Make sure that Pester testing tool is installed and loaded Find-Module Pester | Install-Module Pester Import-...
PowerShellCorpus/PowerShellGallery/xRemoteDesktopSessionHost/1.4.0.0/tests/unit/MSFT_xRDSessionCollection.tests.ps1
MSFT_xRDSessionCollection.tests.ps1
$Global:DSCModuleName = '.\xRemoteDesktopSessionHost' # Example xNetworking $Global:DSCResourceName = 'MSFT_xRDSessionCollection' # Example MSFT_xFirewall #region HEADER [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) if ( (-not (Test...
PowerShellCorpus/PowerShellGallery/xRemoteDesktopSessionHost/1.4.0.0/tests/unit/MSFT_xRDRemoteApp.tests.ps1
MSFT_xRDRemoteApp.tests.ps1
$Global:DSCModuleName = '.\xRemoteDesktopSessionHost' # Example xNetworking $Global:DSCResourceName = 'MSFT_xRDRemoteApp' # Example MSFT_xFirewall #region HEADER [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) if ( (-not (Test-Path -P...
PowerShellCorpus/PowerShellGallery/xRemoteDesktopSessionHost/1.4.0.0/tests/unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
MSFT_xRDSessionCollectionConfiguration.tests.ps1
$Global:DSCModuleName = '.\xRemoteDesktopSessionHost' # Example xNetworking $Global:DSCResourceName = 'MSFT_xRDSessionCollectionConfiguration' # Example MSFT_xFirewall #region HEADER [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) if ...
PowerShellCorpus/PowerShellGallery/xRemoteDesktopSessionHost/1.4.0.0/tests/unit/xRemoteDesktopSessionHost.tests.ps1
xRemoteDesktopSessionHost.tests.ps1
<# .Synopsis Tests for common module for xRemoteDesktopSessionHost .DESCRIPTION Tests for common module for xRemoteDesktopSessionHost .NOTES Code in HEADER and FOOTER regions are standard and may be moved into DSCResource.Tools in Future and therefore should not be altered if possible. #> #...
PowerShellCorpus/PowerShellGallery/_LibraryTest2/1.0.0.1/bin/library.ps1
library.ps1
#region Source Code $source = @' using System; namespace sqlcollective.dbatools { namespace Configuration { using System.Collections; [Serializable] public class Config { public static Hashtable Cfg = new Hashtable(); public string Name...
PowerShellCorpus/PowerShellGallery/oh-my-posh/2.0.111/defaults.ps1
defaults.ps1
# Oh-My-Posh default settings $global:ThemeSettings = New-Object -TypeName PSObject -Property @{ CurrentThemeLocation = "$PSScriptRoot\Themes\Agnoster.psm1" MyThemesLocation = '~\Documents\WindowsPowerShell\PoshThemes' ErrorCount = 0 GitSymbols ...
PowerShellCorpus/PowerShellGallery/oh-my-posh/2.0.111/Helpers/PoshGit.ps1
PoshGit.ps1
#requires -Version 2 -Modules posh-git function Format-BranchName { param( [string] $branchName ) if($spg.BranchNameLimit -gt 0 -and $branchName.Length -gt $spg.BranchNameLimit) { $branchName = ' {0}{1} ' -f $branchName.Substring(0, $spg.BranchNameLimit), $spg.TruncatedBranchSuffix ...
PowerShellCorpus/PowerShellGallery/oh-my-posh/2.0.111/Helpers/Prompt.Tests.ps1
Prompt.Tests.ps1
$global:ThemeSettings = New-Object -TypeName PSObject -Property @{ CurrentThemeLocation = "$PSScriptRoot\Themes\Agnoster.psm1" MyThemesLocation = '~\Documents\WindowsPowerShell\PoshThemes' ErrorCount = 0 PromptSymbols = @{ Star...
PowerShellCorpus/PowerShellGallery/oh-my-posh/2.0.111/Helpers/Prompt.ps1
Prompt.ps1
function Test-IsVanillaWindow { if($env:PROMPT -or $env:ConEmuANSI) { # Console return $false } elseif ($env:TERM_PROGRAM -eq "Hyper") { # Hyper.is return $false } else { # Powershell return $true } } function Get-Home { return $HOME } funct...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/DSCPullServerSetup/PullServerDeploymentVerificationTest/PullServerSetupTests.ps1
PullServerSetupTests.ps1
<# * * Once you setup your pull server with registration, run the following set of tests on the pull server machine * to verify if the pullserver is setup properly and ready to go. #> <# * Prerequisites: * You need Pester module to run this test. * With PowerShell 5, use Install-Module Pester to instal...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xProcessSet_Start.ps1
Sample_xProcessSet_Start.ps1
<# .SYNOPSIS Starts the processes with the executables at the file paths C:\Windows\cmd.exe and C:\TestPath\TestProcess.exe with no arguments. #> Configuration Sample_xProcessSet_Start { [CmdletBinding()] param () Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xServiceSet_StartServices.ps1
Sample_xServiceSet_StartServices.ps1
<# .SYNOPSIS Ensures that the DHCP Client and Windows Firewall services are running. #> Configuration xServiceSetStartExample { Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' xServiceSet ServiceSet1 { Name = @( 'Dhcp', 'MpsSvc' ) Ensure = 'Present' ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xDscWebServiceRegistrationWithSecurityBestPractices.ps1
Sample_xDscWebServiceRegistrationWithSecurityBestPractices.ps1
# DSC configuration for Pull Server using registration with enhanced security settings # The Sample_xDscWebServiceRegistrationWithEnhancedSecurity configuration sets up a DSC pull server that is capable for client nodes # to register with it and retrieve configuration documents with configuration names instead of c...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xMsiPackage_InstallPackageFromFile.ps1
Sample_xMsiPackage_InstallPackageFromFile.ps1
<# .SYNOPSIS Installs the MSI file with the product ID: '{DEADBEEF-80C6-41E6-A1B9-8BDB8A05027F}' at the path: 'file://Examples/example.msi'. Note that the MSI file with the given product ID must already exist at the specified path. The product ID and path value in this file ar...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_InstallMSIProductId_xPackage.ps1
Sample_InstallMSIProductId_xPackage.ps1
<# Simple installer that installs an msi package and matches based on the product id. #> param ( [String]$OutputPath = ".", [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $PackageName, [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $S...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xEnvironment_Remove.ps1
Sample_xEnvironment_Remove.ps1
<# .SYNOPSIS Removes the environment variable 'TestEnvironmentVariable' from both the machine and the process. #> Configuration Sample_xEnvironment_Remove { param () Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' Node localhost { xEnvironment Re...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xArchive_ExpandArchiveDefaultValidationAndForce.ps1
Sample_xArchive_ExpandArchiveDefaultValidationAndForce.ps1
<# .SYNOPSIS Expands the archive located at 'C:\ExampleArchivePath\Archive.zip' to the destination path 'C:\ExampleDestinationPath\Destination'. Since Validate is specified as $true and the Checksum parameter is not provided, the resource will check if the last write time of t...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xDscWebServiceRemoval.ps1
Sample_xDscWebServiceRemoval.ps1
# DSC configuration for removal of Pull Server and Compliance Server configuration Sample_xDscWebService { param ( [string[]]$NodeName = 'localhost' ) Import-DSCResource -ModuleName xPSDesiredStateConfiguration Node $NodeName { WindowsFeature DSCServiceFeature ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsOptionalFeatureSet_Disable.ps1
Sample_xWindowsOptionalFeatureSet_Disable.ps1
<# .SYNOPSIS Disables the Windows optional features TelnetClient and LegacyComponents and removes all files associated with these features. #> Configuration xWindowsOptionalFeatureSet_Disable { Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' xWindowsOptionalFeatureSet...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xUser_Generic.ps1
Sample_xUser_Generic.ps1
param ( [Parameter(Mandatory)] [System.String] $ConfigurationName ) <# Create a custom configuration by passing in whatever values you need. $Password is the only param that is required since it must be a PSCredential object. If you want to create a user with minimal att...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xGroup_RemoveMembers.ps1
Sample_xGroup_RemoveMembers.ps1
<# .SYNOPSIS If the group named GroupName1 does not exist, creates a group named GroupName1. If the group named GroupName1 already exists removes the users that have the usernames Username1 or Username2 from the group. #> Configuration Sample_xGroup_RemoveMembers { [Cmd...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_InstallExeCreds_xPackage.ps1
Sample_InstallExeCreds_xPackage.ps1
<# Simple package that installs an .exe using credentials to access the installer and specifying RunAs Credentials. #> param ( [String]$OutputPath = ".", [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $PackageName, [parameter(Mandatory = $true)] [ValidateNo...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsOptionalFeature.ps1
Sample_xWindowsOptionalFeature.ps1
<# .SYNOPSIS Enables the Windows optional feature with the specified name and outputs a log to the specified path. .PARAMETER FeatureName The name of the Windows optional feature to enable. .PARAMETER LogPath The path to the file to log the enable operation to. .NOTE...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xRemoteFileUsingProxy.ps1
Sample_xRemoteFileUsingProxy.ps1
configuration Sample_xRemoteFile_DownloadFileUsingProxy { param ( [string[]] $nodeName = 'localhost', [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $destinationPath, [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsProcess_StartUnderUser.ps1
Sample_xWindowsProcess_StartUnderUser.ps1
<# .SYNOPSIS Starts the gpresult process under the given credential which generates a log about the group policy. The path to the log is provided in 'Arguments'. .PARAMETER Credential Credential to start the process under. #> Configuration Sample_xWindowsProcess_StartUnderUser ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xService_DeleteService.ps1
Sample_xService_DeleteService.ps1
<# .SYNOPSIS Stops and then removes the service with the name Service1. #> Configuration Sample_xService_DeleteService { [CmdletBinding()] param () Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' Node localhost { xService ServiceResource1 ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xGroup_SetMembers.ps1
Sample_xGroup_SetMembers.ps1
<# .SYNOPSIS If the group named GroupName1 does not exist, creates a group named GroupName1 and adds the users with the usernames Username1 and Username2 to the group. If the group named GroupName1 already exists, removes any users that do not have the usernames Userna...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsProcess_Start.ps1
Sample_xWindowsProcess_Start.ps1
<# .SYNOPSIS Starts the gpresult process which generates a log about the group policy. The path to the log is provided in 'Arguments'. #> Configuration Sample_xWindowsProcess_Start { param () Import-DSCResource -ModuleName 'xPSDesiredStateConfiguration' Node localhost ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xArchive_ExpandArchiveChecksumAndForce.ps1
Sample_xArchive_ExpandArchiveChecksumAndForce.ps1
<# .SYNOPSIS Expands the archive located at 'C:\ExampleArchivePath\Archive.zip' to the destination path 'C:\ExampleDestinationPath\Destination'. Since Validate is specified as $true and the Checksum parameter is specified as SHA-256, the resource will check if the SHA-256 hash...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xService_UpdateStartupTypeIgnoreState.ps1
Sample_xService_UpdateStartupTypeIgnoreState.ps1
<# .SYNOPSIS If the service with the name Service1 does not exist, this configuration would throw an error since the Path is not included here. If the service with the name Service1 already exists, sets the startup type of the service with the name Service1 to Manual and ignor...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xRemoteFile.ps1
Sample_xRemoteFile.ps1
configuration Sample_xRemoteFile_DownloadFile { param ( [string[]] $nodeName = 'localhost', [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $destinationPath, [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsFeature.ps1
Sample_xWindowsFeature.ps1
<# Create a custom configuration by passing in whatever values you need. $Name is the only parameter that is required which indicates which Windows Feature you want to install (or uninstall if you set Ensure to Absent). LogPath and Credential are not included here, but if you would like to specify ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xScript.ps1
Sample_xScript.ps1
<# .SYNOPSIS Creates a file at the given file path with the specified content through the xScript resource. .PARAMETER FilePath The path at which to create the file. .PARAMETER FileContent The content to set for the new file. #> Configuration xScriptExample { [Cmdlet...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xArchive_RemoveArchiveChecksum.ps1
Sample_xArchive_RemoveArchiveChecksum.ps1
<# .SYNOPSIS Remove the expansion of the archive located at 'C:\ExampleArchivePath\Archive.zip' from the destination path 'C:\ExampleDestinationPath\Destination'. Since Validate is specified as $true and the Checksum parameter is specified as SHA-256, the resource will check i...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xProcessSet_Stop.ps1
Sample_xProcessSet_Stop.ps1
<# .SYNOPSIS Stops the processes with the executables at the file paths C:\Windows\cmd.exe and C:\TestPath\TestProcess.exe with no arguments and logs any output to the path C:\OutputPath\Output.log. #> Configuration Sample_xProcessSet_Stop { [CmdletBinding()] param () ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsPackageCab.ps1
Sample_xWindowsPackageCab.ps1
<# .SYNOPSIS Installs a package from the cab file with the specified name from the specified source path and outputs a log to the specified log path. .PARAMETER Name The name of the package to install. .PARAMETER SourcePath The path to the cab file to install the p...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xGroupSet_AddMembers.ps1
Sample_xGroupSet_AddMembers.ps1
<# .SYNOPSIS If the groups named GroupName1 and Administrators do not exist, creates the groups named GroupName1 and Administrators and adds the users with the usernames Username1 and Username2 to both groups. If the groups named GroupName1 and Administrators already e...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xMsiPackage_UnstallPackageFromHttps.ps1
Sample_xMsiPackage_UnstallPackageFromHttps.ps1
<# .SYNOPSIS Uninstalls the MSI file with the product ID: '{DEADBEEF-80C6-41E6-A1B9-8BDB8A05027F}' at the path: 'https://Examples/example.msi'. Note that the MSI file with the given product ID must already exist on the server. The product ID and path value in this file are pro...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xUser_CreateUser.ps1
Sample_xUser_CreateUser.ps1
Configuration xUserExample { param ( [System.Management.Automation.PSCredential] $PasswordCredential ) Import-DscResource -ModuleName xPSDesiredStateConfiguration xUser xUserExample { Ensure = 'Present' # To ensure the user account does not exist, set Ensure to ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsFeatureSet_Uninstall.ps1
Sample_xWindowsFeatureSet_Uninstall.ps1
<# .SYNOPSIS Uninstalls the TelnetClient and RSAT-File-Services Windows features, including all their subfeatures. Logs the operation to the file at 'C:\LogPath\Log.log'. #> Configuration xWindowsFeatureSetExample_Install { [CmdletBinding()] param () Import-DscResource -Module...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xRegistryResource_RemoveKey.ps1
Sample_xRegistryResource_RemoveKey.ps1
<# .SYNOPSIS Removes the registry key called MyNewKey under the parent key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'. #> Configuration Sample_xRegistryResource_RemoveKey { Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' Node localhost {...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xMsiPackage_InstallPackageFromHttp.ps1
Sample_xMsiPackage_InstallPackageFromHttp.ps1
<# .SYNOPSIS Installs the MSI file with the product ID: '{DEADBEEF-80C6-41E6-A1B9-8BDB8A05027F}' at the path: 'http://Examples/example.msi'. Note that the MSI file with the given product ID must already exist on the server. The product ID and path value in this file are provid...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xServiceSet_BuiltInAccount.ps1
Sample_xServiceSet_BuiltInAccount.ps1
<# .SYNOPSIS Sets the Secure Socket Tunneling Protocol and DHCP Client services to run under the built-in account LocalService. #> Configuration xServiceSetBuiltInAccountExample { Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' xServiceSet ServiceSet1 { ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xService_CreateService.ps1
Sample_xService_CreateService.ps1
<# .SYNOPSIS If the service with the name Service1 does not exist, creates the service with the name Service1 and the executable/binary path 'C:\FilePath\MyServiceExecutable.exe'. The new service will be started by default. If the service with the name Service1 already exists,...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xEnvironment_CreatePathVariable.ps1
Sample_xEnvironment_CreatePathVariable.ps1
<# .SYNOPSIS Creates the environment variable 'TestPathEnvironmentVariable' and sets the value to 'TestValue' if it doesn't already exist or appends the value 'TestValue' to the existing path if it does already exist on the machine and within the process. #> Configuration Sample_xEnvir...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xRegistryResource_RemoveValue.ps1
Sample_xRegistryResource_RemoveValue.ps1
<# .SYNOPSIS Removes the registry key value MyValue from the key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'. #> Configuration Sample_xRegistryResource_RemoveValue { Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' Node localhost { ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsFeatureSet_Install.ps1
Sample_xWindowsFeatureSet_Install.ps1
<# .SYNOPSIS Installs the TelnetClient and RSAT-File-Services Windows features, including all their subfeatures. Logs the operation to the file at 'C:\LogPath\Log.log'. #> Configuration xWindowsFeatureSetExample_Install { [CmdletBinding()] param () Import-DscResource -ModuleNa...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xEnvironment_CreateNonPathVariable.ps1
Sample_xEnvironment_CreateNonPathVariable.ps1
<# .SYNOPSIS Creates the environment variable 'TestEnvironmentVariable' and sets the value to 'TestValue' both on the machine and within the process. #> Configuration Sample_xEnvironment_CreateNonPathVariable { param () Import-DscResource -ModuleName 'xPSDesiredStateConfiguration'...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xArchive_ExpandArchiveNoValidation.ps1
Sample_xArchive_ExpandArchiveNoValidation.ps1
<# .SYNOPSIS Expands the archive located at 'C:\ExampleArchivePath\Archive.zip' to the destination path 'C:\ExampleDestinationPath\Destination'. The resource will only check if the expanded archive files exist at the destination. No validation is performed on any existing fil...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_InstallMSI_xPackage.ps1
Sample_InstallMSI_xPackage.ps1
<# Simple installer for an msi package that matches via the Name. #> param ( [String]$OutputPath = ".", [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $PackageName, [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $SourcePath ) Conf...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xMsiPackage_UninstallPackageFromFile.ps1
Sample_xMsiPackage_UninstallPackageFromFile.ps1
<# .SYNOPSIS Uninstalls the MSI file with the product ID: '{DEADBEEF-80C6-41E6-A1B9-8BDB8A05027F}' at the path: 'file://Examples/example.msi'. Note that the MSI file with the given product ID must already exist at the specified path. The product ID and path value in this file ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xArchive_ExpandArchiveNoValidationCredential.ps1
Sample_xArchive_ExpandArchiveNoValidationCredential.ps1
<# .SYNOPSIS Expands the archive located at 'C:\ExampleArchivePath\Archive.zip' to the destination path 'C:\ExampleDestinationPath\Destination'. The added specification of a Credential here allows you to provide the credential of a user to provide the resource access to the ar...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsProcess_StopUnderUser.ps1
Sample_xWindowsProcess_StopUnderUser.ps1
<# .SYNOPSIS Stops the gpresult process running under the given credential if it is running. Since the Arguments parameter isn't needed to stop the process, an empty string is passed in. .PARAMETER Credential Credential that the process is running under. #> Configuratio...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xDscWebServiceRegistration.ps1
Sample_xDscWebServiceRegistration.ps1
# DSC configuration for Pull Server using registration # The Sample_xDscWebServiceRegistration configuration sets up a DSC pull server that is capable for client nodes # to register with it and retrieve configuration documents with configuration names instead of configuration id # Prerequisite: Install a certifi...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsProcess_Stop.ps1
Sample_xWindowsProcess_Stop.ps1
<# .SYNOPSIS Stops the gpresult process if it is running. Since the Arguments parameter isn't needed to stop the process, an empty string is passed in. #> Configuration Sample_xWindowsProcess_Stop { param () Import-DSCResource -ModuleName 'xPSDesiredStateConfiguratio...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xWindowsOptionalFeatureSet_Enable.ps1
Sample_xWindowsOptionalFeatureSet_Enable.ps1
<# .SYNOPSIS Enables the Windows optional features MicrosoftWindowsPowerShellV2 and Internet-Explorer-Optional-amd64 and outputs a log of the operations to a file at the path 'C:\LogPath\Log.txt'. #> Configuration xWindowsOptionalFeatureSet_Enable { Import-DscResource -ModuleName...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xRegistryResource_AddKey.ps1
Sample_xRegistryResource_AddKey.ps1
<# .SYNOPSIS Create a new registry key called MyNewKey as a subkey under the key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'. #> Configuration Sample_xRegistryResource_AddKey { Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' Node localhost ...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_InstallExeCredsRegistry_xPackage.ps1
Sample_InstallExeCredsRegistry_xPackage.ps1
<# Simple package that installs an .exe using credentials to access the installer and specifying RunAs Credentials. This sample also uses custom registry data to discover the package. #> param ( [String]$OutputPath = ".", [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [String] $...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xPSSessionConfiguration.ps1
Sample_xPSSessionConfiguration.ps1
configuration Sample_xPSEndpoint_NewWithDefaults { param ( [Parameter(Mandatory)] [String]$Name ) Import-DscResource -module xPSDesiredStateConfiguration xPSEndpoint PSSessionConfiguration { Name = $Name Ensure = 'Present' } } configuration...
PowerShellCorpus/PowerShellGallery/xPSDesiredStateConfiguration/6.4.0.0/Examples/Sample_xRegistryResource_AddOrModifyValue.ps1
Sample_xRegistryResource_AddOrModifyValue.ps1
<# .SYNOPSIS If the registry key value MyValue under the key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' does not exist, creates it with the Binary value 0. If the registry key value MyValue under the key 'HKLM:\SYSTEM\CurrentControlSet\Contro...