full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Test/test-objecttemplate.ps1
test-objecttemplate.ps1
$template = get-scsmobjecttemplate -name HighPriorityIncidentTemplate $high = (get-scsmenumeration System.WorkItem.TroubleTicket.UrgencyEnum.High).id # find a projection which we can test against $p = Get-SCSMObjectProjection system.workitem.incident.projectiontype -sort Status -filter "Urgency -ne '$high'" -max...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Test/initialize-knowledgearticle.ps1
initialize-knowledgearticle.ps1
param ( $count = 1) BEGIN { # the definition of Out-TestLog . ./Common.ps1 $TESTNAME = $MyInvocation.MyCommand $DOCUMENT = "${PWD}\Document.RTF" $class = get-scsmclass "System.Knowledge.Article" # get rid of the article we're creating get-scsmobject -class $class -filter "DisplayNam...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Test/test002.ps1
test002.ps1
# this makes sure that all the cmdlets have a ComputerName and Credential # parameter except for the ones that shouldn't # this test ensures that the cmdlets that should be here are here BEGIN { # the definition of Out-TestLog . ./Common.ps1 $TESTNAME = $MyInvocation.MyCommand $STARTTIME = [...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Test/test001.ps1
test001.ps1
# this test ensures that the cmdlets that should be here are here BEGIN { # the definition of Out-TestLog . ./Common.ps1 $TESTNAME = $MyInvocation.MyCommand $STARTTIME = [datetime]::Now } END { $Expected = "Add-SCSMEnumeration", "Add-SCSMRequestOffering", "Export-SCManagementPac...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Test/Common.ps1
Common.ps1
$LOGFILE = "TestLog.txt" $TESTDIR = (split-path $myInvocation.mycommand.definition) $OUTLOG = "$TESTDIR\$LOGFILE" function Out-TestLog { param ( [string]$message ) $message | out-file -append $OUTLOG }
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Test/test003.ps1
test003.ps1
BEGIN { # the definition of Out-TestLog . ./Common.ps1 $TESTNAME = $MyInvocation.MyCommand $STARTTIME = [datetime]::Now } END { try { $a = get-scsmRule foreach($rule in $a) { $b = [smlets.workflowhelper]::GetJobStatus($rule) # once we have a winner, don't conti...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/get-componentTree.ps1
get-componentTree.ps1
param ( $projectionname = "Microsoft.Windows.Computer.ProjectionType" ) function Get-Components { param ( $object, $indent ) if ( ! $object.__base.Parent -and $object.__base.Name) { write-host -for yellow $object.__base.Name new-object psobject -prop @{ Indent ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-ChangeRequest.ps1
Initialize-ChangeRequest.ps1
param ( $count = 1, [switch]$whatif, [switch]$verbose ) BEGIN { . ./Common.ps1 $global:IDD = new-object Microsoft.EnterpriseManagement.ConnectorFramework.IncrementalDiscoveryData $EMG = @(get-scsmsession)[0] # A USER $user = get-scsmobject (get-scsmclass ^System.User$) -filter "DisplayName -l...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-DemoData.ps1
Initialize-DemoData.ps1
[CmdletBinding()] param ( [Parameter()] [ValidateSet("tiny","100","500","1k","10k","20k")] $size = "tiny", [Parameter()] [Switch]$whatif, # a parameter to just create one of each [Parameter()] [int]$count ) # # This file contains various profile information for ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/initialize-group.ps1
initialize-group.ps1
param ( $count = 5, [switch]$whatif, [switch]$verbose ) . ./Common.ps1 $computerClass = get-scsmclass System.Computer$ -verbose:$verbose $computerList = get-scsmobject $computerClass -verbose:$verbose $NewMPArgs = @{ ManagementPackName = "AnMPForGroups" FriendlyName = "DataGen Group Management Pack"...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/New-ReleaseRecord.ps1
New-ReleaseRecord.ps1
param ( $count = 1, $ComputerName = "localhost" ) BEGIN { . ./Common.ps1 $IDD = new-object Microsoft.EnterpriseManagement.ConnectorFramework.IncrementalDiscoveryData $EMG = new-object Microsoft.EnterpriseManagement.EnterpriseManagementGroup $computername # A USER $user = get-scsmobject ^Syste...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-ComputerInstance.ps1
Initialize-ComputerInstance.ps1
param ( [int]$count = 100, [switch]$whatif, [switch]$verbose, [switch]$progress, $domain ) . ./Common.ps1 $class = get-scsmclass Microsoft.Windows.Computer$ $Status = get-scsmenumeration System.ConfigItem.AssetStatusEnum.Deployed if ( $domain ) { $DName = $domain { else { $DName = $env:userdomain } $A...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-Service.ps1
Initialize-Service.ps1
param ( [int]$count = 1, [switch]$whatif, [switch]$verbose, [switch]$nobulk ) . ./Common.ps1 $userList = get-scsmobject (get-scsmclass Microsoft.AD.User$) -filter "LastName -like '%'" $computerList = get-scsmobject (get-scsmclass System.Computer$) -max 60 $serviceGrouplist = get-scsmclass | ?{$_.getbasety...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/set-billabletime.ps1
set-billabletime.ps1
$bt1 = Get-SCSMRelationshipClass billabletimehas $bt2 = Get-SCSMRelationshipClass billabletime$ $btc = get-scsmclass system.workitem.billabletime $users = get-scsmobject Microsoft.AD.User -filter "FirstName -like '%'" $random = new-object random get-scsmobject System.WorkItem.Incident | %{ $wi = $_ $u = ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-ReleaseRecord.ps1
Initialize-ReleaseRecord.ps1
param ( $count = 1, $ComputerName = "localhost", [switch]$whatif, [switch]$verbose ) BEGIN { . ./Common.ps1 $IDD = new-object Microsoft.EnterpriseManagement.ConnectorFramework.IncrementalDiscoveryData $EMG = new-object Microsoft.EnterpriseManagement.EnterpriseManagementGroup $computername # A USER...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-User.ps1
Initialize-User.ps1
param ( [int]$count = 100, [switch]$whatif, [switch]$verbose, [string]$domain, [switch]$nobulk, [switch]$force ) . ./common.ps1 $class = get-scsmclass Microsoft.AD.User$ if ( $domain ) { $DName = $domain } else { $DName = $env:userdomain } $userdb = get-scsmuser if ( ($userdb.count -gt $count) -and ! $for...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/initialize-ComputerProjection.ps1
initialize-ComputerProjection.ps1
param ( [int]$count = 100, [switch]$whatif, [switch]$verbose, [switch]$progress, [string]$computerPrefix = "Computer", [string]$domain, [switch]$noBulk ) . ./Common.ps1 $userClass = get-scsmclass "^Microsoft.AD.User$" -verbose:$verbose $userList = get-scsmobject $userClass -verbose:$verbose $computerClass = get...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Remove-DemoData.ps1
Remove-DemoData.ps1
param ( [switch]$whatif, [switch]$verbose ) "NOT READY YET" EXIT $classes = "^System.WorkItem.ChangeRequest$", "^Microsoft.AD.User$", "^System.SoftwareItem$", "^System.SoftwareUpdate$", "^Microsoft.AD.Printer$", "^Microsoft.Windows.Computer$", "^System.WorkItem.ReleaseRecord$", "^S...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/initialize-knowledgearticle.ps1
initialize-knowledgearticle.ps1
param ( $count = 20, [switch]$whatif, [switch]$verbose) BEGIN { # the definition of Out-TestLog . ./Common.ps1 $TESTNAME = $MyInvocation.MyCommand $DOCUMENT = "${PWD}\Document.RTF" $class = get-scsmclass "System.Knowledge.Article" # get rid of the article we're creating get-scsmobje...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-Problem.ps1
Initialize-Problem.ps1
param ( $count = 10 , [switch]$whatif, [switch]$Verbose, [switch]$debug, [switch]$nobulk ) BEGIN { . ./Common.ps1 $RANDOM = new-object System.Random $PTYPE = "System.WorkItem.Problem.ProjectionType" ### ### SETUP ### Retrieve stuff from the CMDB which will be used later ### ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-Printer.ps1
Initialize-Printer.ps1
param ( $count = 10, [switch]$whatif, [switch]$verbose, [string]$prefix = "Printer",[switch]$nobulk ) . ./Common.ps1 $Printer = get-scsmclass Microsoft.AD.Printer -verbose:$verbose $computerClass = get-scsmclass "^Microsoft.Windows.Computer$" $computerList = get-scsmobject $computerClass -verbose:$verbose $P...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/initialize-queue.ps1
initialize-queue.ps1
param ( $count = 5, [switch]$whatif, [switch]$verbose ) . ./Common.ps1 $class = get-scsmclass System.WorkItem.Incident$ Get-SCSMManagementPack anmpforqueues | remove-scsmmanagementpack $NewMPArgs = @{ ManagementPackName = "AnMPForQueues" FriendlyName = "DataGen Queue Management Pack" Verbose ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-ComputerProjectionPeripherals.ps1
Initialize-ComputerProjectionPeripherals.ps1
param ( [switch]$whatif, [switch]$verbose, [switch]$nuke, [switch]$view , [switch]$raw) . ./Common.ps1 # Use WMI to get mimic details about the peripherals needed # by the ComputerProjection # The list of devices: # PhysicalComputer # OperatingSystem # NetworkAdapter # Processor # PhysicalDisk ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Common.ps1
Common.ps1
$ACTIVITYHASREVIEWERRELATIONSHIP = Get-SCSMRelationshipClass System.ReviewActivityHasReviewer $REVIEWERISUSERRELATIONSHIP = Get-SCSMRelationshipClass System.ReviewerIsUser $WORKITEMCREATEDBYUSERRELATIONSHIP = Get-SCSMRelationshipClass System.WorkitemCreatedByUser $ASSIGNEDTOUSERRELATIONSHIP = Get-S...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/initialize-incident.ps1
initialize-incident.ps1
param ( $count = 10 , [switch]$whatif, [switch]$Verbose, [switch]$nobulk ) BEGIN { . ./Common.ps1 $RANDOM = new-object System.Random $PTYPE = "System.WorkItem.Incident.ProjectionType" ### ### SETUP ### Retrieve stuff from the CMDB which will be used later ### Write-Progr...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-RequestFromRO.ps1
Initialize-RequestFromRO.ps1
param ( $count = 2, [switch]$whatif, [switch]$verbose, $requestOfferingName = "*" ) # in this case, it is count per RequestOffering Write-Progress -Status Retrieving -Activity "Request Offerings" $ros = get-scsmrequestoffering -published -displayname $requestOfferingName -verbose:$verbose $random = new-object s...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/values.ps1
values.ps1
# this is a 3 month load # rate is $User20KCounts = @{ Microsoft.AD.Group = 200 Microsoft.AD.Printer = 800 Microsoft.AD.User = 20000 Microsoft.SystemCenter.BusinessService = 30 Microsoft.SystemCenter.ConfigurationManager.DeployedComputer = 20000 Microsoft.Windows.Client.Computer = 1...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/initialize-SoftwareUpdate.ps1
initialize-SoftwareUpdate.ps1
param ( $count = 10, [switch]$whatif, [switch]$verbose ) . ./Common.ps1 $softwareUpdateClass = get-scsmclass System.SoftwareUpdate $computerClass = get-scsmclass ^System.Computer$ # this is completely made up and has no real data behind it # $VendorList = 1..8 | %{ Get-Lorem 2 } 1..$count | %{ $current = 0...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/compit.ps1
compit.ps1
$v = "SELECT 'BME' as ElementName, COU", "SELECT 'TME' as ElementName, COU", "SELECT 'RelationshipBME' as Elem", "SELECT 'EntityChangeLogBME' as E", "SELECT 'RecursiveMembership' as", "SELECT 'JobStatus' as ElementNam" foreach($val in $v) { $tt = ($a |?{$_.query -match $val }) $after = ($a |?{$_.qu...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/initialize-SoftwareItem.ps1
initialize-SoftwareItem.ps1
param ( $count = 100, [switch]$whatif, [switch]$verbose ) . ./Common.ps1 $SoftwareItem = get-scsmclass System.SoftwareItem $computerClass = get-scsmclass ^System.Computer$ # Write-Progress -Activity "Querying WMI for Win32_Product" -Status "Get-WMIObject Win32_Product" # WMI Takes too long to get the data, w...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/DataGen/Initialize-Change.ps1
Initialize-Change.ps1
param ( $count = 10 , [switch]$whatif, [switch]$Verbose, [switch]$debug) BEGIN { . ./Common.ps1 $PTYPE = "System.WorkItem.ChangeRequestProjection" # RESOURCES NEEDED BUILT BY COMMON.PS1 # # INSTANCEHASH[$UserClass] # INSTANCEHASH[$CIClass] # ENUMHASH["ProblemStatusEnum"] ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Get-EnumStack.ps1
Get-EnumStack.ps1
function Get-ParentEnum { param ( $enum ) if ( ! $enum ) { return } write-host -for blue $enum if ( $enum -is [string] ) { $enum = get-scsmEnumeration "^${enum}$" } if ( $enum -is [guid] ) { $enum = Get-SCSMEnumeration -id $enum } if ( $enum.Parent ) { write-host -for red $e...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-SCSMProjectionComponent.ps1
get-SCSMProjectionComponent.ps1
[CmdletBinding()] param ( [Parameter(Mandatory=$true,ValueFromPipeline=$true)]$projection ) Process { if ( $projection.__base -isnot "Microsoft.EnterpriseManagement.Configuration.ManagementPackTypeProjection" ) { throw "$projection is not a projection" } ,$projection.ComponentC...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Get-SMConfig.ps1
Get-SMConfig.ps1
# a script to retrieve information about a running SM installation # we need to collect the following: # The Setup logs: # $env:homedrive\$env:homepath\appdata\local\scsm\setup\*.log # the Enumeration of SM administrators role and members # the runas profiles and members # service config info for health...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/test-SupportGroupConfig.ps1
test-SupportGroupConfig.ps1
param ($file, $parentenumname, $verbose = $true) #For Debugging Only # $file = "C:\Users\Administrator\Documents\Software\CodePlex\SMLets\Main\Source\SMLets\SMLets\Scripts\SupportGroups.txt" #$SupportGroups = Get-Content $file $SupportGroups = "Group1","Group2" $supportGroups $parentenumname = "CANRootEnum" ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/New-MPBFile.ps1
New-MPBFile.ps1
# New-MPBFile.ps1 # this takes files (.mp or .xml) and creates a .mpb file param ( $mpFile = $( throw "Must have mpfile" ), [string]$mpbname = "testmpb", $computername = "localhost", [switch]$useFileStore, [switch]$debug ) # VARIABLES NEEDED BY SCRIPT $VerbosePreference = "continue" ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-taskparameters.ps1
get-taskparameters.ps1
param ( $taskname = '.*' ) $emg = new-object Microsoft.EnterpriseManagement.EnterpriseManagementGroup localhost $tasks = $emg.TaskConfiguration.GetTasks()|?{$_.name -match $taskname } $tasks | %{ $_.GetOverrideableParameters() } | ft -group ParentElement Name,ParameterType,Selector -au
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Restore-SCSMDeletedItem.ps1
Restore-SCSMDeletedItem.ps1
[CmdletBinding()] param ( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] $DeletedObject, [Parameter()][Switch]$PassThru, [Parameter()][Switch]$whatif ) Process { $DeletedObject | set-scsmobject -ph @{ ObjectStatus = "Active" } -whatif:$whatif -passthru:$passthru }
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Export-BundleContents.ps1
Export-BundleContents.ps1
[CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter(ValueFromPipelineByPropertyName=$true,Position=0,Mandatory=$true)][string[]]$fullname, [Parameter()][switch]$mponly ) Begin { # VARIABLES NEEDED BY SCRIPT $VerbosePreference = "continue" $MPTYPE = "Microsoft.EnterpriseM...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-smtask.ps1
get-smtask.ps1
param ( $computername = "localhost" ) [reflection.assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core")|out-null $EMG = new-object Microsoft.EnterpriseManagement.EnterpriseManagementGroup $computername $EMG.TaskConfiguration.GetTasks()
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-mpbinfo.ps1
get-mpbinfo.ps1
#requires -version 2.0 # required because of the way we use new-object # Get-MPBInfo.ps1 # Retrieve management pack and resource information from a .MPB file param ( $file, $computername = "localhost", [switch]$mpinfo, [switch]$dumpStream ) $PACKDLL = "Microsoft.EnterpriseManagement.Packaging" $FSTYPE = "Microso...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Set-LastModified.ps1
Set-LastModified.ps1
param ( $date = 30, [switch]$whatif ) BEGIN { if ( $date -is [datetime] ) { if ( $date -gt [datetime]::Now ) { throw "must have a date before now" } } else { if ( $date -is [int] ) { $date = [datetime]::Now.AddDays(-$date)...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Get-SCSMWorkflow.ps1
Get-SCSMWorkflow.ps1
param ( $RuleName = ".*" , [switch]$status ) $asm = [reflection.assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core") if ( ! $asm ) { throw "Could not load SM CORE dll, exiting" } $EMGTYPE = "microsoft.enterprisemanagement.enterprisemanagementgroup" if ( $emg -isnot $EMGTYPE ) { $emg = new-object ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-scsmdeleteditem.ps1
get-scsmdeleteditem.ps1
param ( $filter = $true ) if ( $filter -eq $true ) { } elseif ( $filter -match "(.*) (-like|-eq|-ne|) (.*)" ) { $filter = $filter -replace "%","*" $filter = '$_.' + $filter } else { throw "bad filter $filter" } $sb = $executioncontext.InvokeCommand.NewScriptBlock($filter) get-scsmobject -cla...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-smtaskresult.ps1
get-smtaskresult.ps1
param ( $batchid, $computername = "localhost" ) $EMGT = "Microsoft.EnterpriseManagement.EnterpriseManagementGroup" $EMG = new-object $EMGT $computername if ( $batchid ) { $emg.TaskRuntime.GetTaskResultsByBatchId($batchid) } else { $emg.TaskRuntime.GetTaskResults() }
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-lorem.ps1
get-lorem.ps1
param ( [int]$count = 11, [switch]$Start ) #$s = $Start.ToString().ToLower() #$URL = Ā"http://www.lipsum.com/feed/xml?amount=${count}&what=words&start=${s}" #[xml]$x = ((new-object net.webclient).downloadstring($URL)) #$x.feed.lipsum $words = "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod"...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/objectcriteria.ps1
objectcriteria.ps1
$c = get-scsmclass ManualActivity$ $CriteriaT = "Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria" $now = [datetime]::Now new-object $CriteriaT "Name == 'zowee'",$c new-object $CriteriaT "TimeAdded < '$now'",$c new-object $CriteriaT "TimeAdded > '$now'",$c new-object $CriteriaT "Name like ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-singlepropertycriteria.ps1
get-singlepropertycriteria.ps1
param ( [Parameter(Mandatory=$true,Position=0)][Microsoft.EnterpriseManagement.Configuration.ManagementPackProperty]$property, [Parameter(Mandatory=$true,Position=1)][string]$op, [Parameter(Mandatory=$true,Position=2)][string]$value, [switch]$stringOnly ) # Create the expression XML...somet...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/test-relationshipobject.ps1
test-relationshipobject.ps1
$btr = get-scsmrelationshipclass System.WorkItem.BillableTimeHasWorkingUser # Source is user # target is Billable Time $source = get-scsmobject -class (get-scsmclass -name System.User$) -filter "DisplayName -like 'Travis%'" $target = get-scsmobject -class (get-scsmclass -name System.WorkItem.BillableTime) | select ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Test-SCManagementPack.ps1
Test-SCManagementPack.ps1
#requires -version 2.0 param ( [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] [string[]]$fullname ) BEGIN { # GLOBAL REFERENCES # $SMDIR $NS = "Microsoft.EnterpriseManagement" [reflection.assembly]::LoadWithPartialName("${NS}.Core")|out-null $EMG = new-object "${NS}.Enterpr...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Update-MPVersion.ps1
Update-MPVersion.ps1
[CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter(Position=0,Mandatory=$true)]$ManagementPackFile , [Parameter()][Switch]$MajorIncrement, [Parameter()][Switch]$MinorIncrement, [Parameter()][Switch]$BuildIncrement, [Parameter()][Switch]$RevisionIncrement, [Parameter()][Switc...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Export-KnowledgeArticle.ps1
Export-KnowledgeArticle.ps1
#requires -version 2.0 [CmdletBinding(SupportsShouldProcess=$true)] param ( [parameter(Position=0)][string]$computerName = "localhost" ) BEGIN { $articles = get-scsmclass knowledge.ar|get-scsmobject [reflection.assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.Core")|out-null ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/new-criteria.ps1
new-criteria.ps1
param ( [Parameter(Position=0,Mandatory=$true)] [Microsoft.EnterpriseManagement.Configuration.ManagementPackClass]$class, [Parameter(Position=1,Mandatory=$true)][scriptblock]$sb, [Parameter()][switch]$xmlonly ) $mpName = $class.GetManagementPack().Name $mpVers = $class.GetManagementPack().V...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/Set-IncidentUser.ps1
Set-IncidentUser.ps1
#requires -version 2.0 [CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter()][string]$AssignedTo, [Parameter()][string]$Affected, [Parameter(ValueFromPipeline=$true)]$TheIncident ) BEGIN { $NS = "Microsoft.EnterpriseManagement" $EMGType = "${NS}.EnterpriseManagementGroup" ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/display-richtext.ps1
display-richtext.ps1
param ( $string, [byte[]]$bytes , $object ) begin { [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms") [void][reflection.assembly]::LoadWithPartialName("System.Drawing") ## the form $form = new-object System.Windows.Forms.Form $form.size = new-objec...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-smproperty.ps1
get-smproperty.ps1
[CmdletBinding(DefaultParameterSetName="name")] param ( [Parameter(Position=0,ParameterSetName="name",Mandatory=$true)][string]$classname, [Parameter(Position=0,ParameterSetName="class",Mandatory=$true,ValueFromPipeline=$true)] [Microsoft.EnterpriseManagement.Configuration.ManagementPackClass]$class = ...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-SCSMSubscription.ps1
get-SCSMSubscription.ps1
Get-SCSMRule| ?{ $_.WriteActionCollection | ?{ $_.Configuration -match "SendNotificationsActivity"}}| %{ $_.psobject.typenames[0] = "ManagementPackRule#NotificationSubscription"; $_ } #$coll | %{ # $_.psobject.typenames[0] = "ManagementPackRule#NotificationSubscription" # $_ | Add-member -pass Not...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-ROQuestions.ps1
get-ROQuestions.ps1
param ( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)]$RequestOffering ) PROCESS { $RoObject = new-object psobject $RoObject | add-member NotePRoperty RequestOffering $RequestOffering $RoObject | add-member NoteProperty Questions @() $Template = [xml]$RequestOffering.Pre...
PowerShellCorpus/PowerShellGallery/SMLets/0.5.0.1/Scripts/get-scsmuser.ps1
get-scsmuser.ps1
[CmdletBinding(DefaultParameterSetName="username")] param ( [Parameter(ParameterSetName="username")]$username = '*', [Parameter(ParameterSetName="first")]$first, [Parameter(ParameterSetName="last")]$last, [Parameter(ParameterSetName="filter")]$filter = $null ) if ( $username -ne $null ) ...
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/private/PrivateVariables.ps1
PrivateVariables.ps1
$script:sqsequences = @{}
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/public/Read-SQSequences.ps1
Read-SQSequences.ps1
Function Read-SQSequences { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$Path, [Parameter(Mandatory=$false)] [bool]$InitializeEmptyIfFileDoesNotExist = $false) Clear-SQAllSequences if (!(Test-Path -Path $path -PathType Leaf)) { Save-SQSequences -Path $path } $obj =...
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/public/Get-SQNextSequenceValue.ps1
Get-SQNextSequenceValue.ps1
Function Get-SQNextSequenceValue { [CmdletBinding()] Param([Parameter(Mandatory=$false)] [string]$SequenceName = 'default') $sequences = $script:sqsequences if (!($sequences.ContainsKey($SequenceName))) { $sequences.Add($SequenceName, 0) 0 | Write-Output } else { $value = $sequences[$S...
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/public/Clear-SQAllSequences.ps1
Clear-SQAllSequences.ps1
Function Clear-SQAllSequences { [CmdletBinding()] Param() $script:sqsequences = @{} }
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/public/Clear-SQSequence.ps1
Clear-SQSequence.ps1
Function Clear-SQSequence { [CmdletBinding()] Param([Parameter(Mandatory=$false)] [string]$SequenceName = 'default') $sequences = $script:sqsequences if ($sequences.ContainsKey($SequenceName)) { $sequences.Remove($SequenceName) } }
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/public/Set-SQCurrentSequenceValue.ps1
Set-SQCurrentSequenceValue.ps1
Function Set-SQCurrentSequenceValue { [CmdletBinding()] Param([Parameter(Mandatory=$false)] [string]$SequenceName = 'default', [Parameter(Mandatory=$true)] [int]$Value) $sequences = $script:sqsequences Clear-SQSequence -SequenceName $SequenceName $sequences.Add($SequenceName, $Value) }
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/public/Get-SQCurrentSequenceValue.ps1
Get-SQCurrentSequenceValue.ps1
Function Get-SQCurrentSequenceValue { [CmdletBinding()] Param([Parameter(Mandatory=$false)] [string]$SequenceName = 'default') $sequences = $script:sqsequences if ($sequences.ContainsKey($SequenceName)) { $sequences[$SequenceName] | Write-Output } else { 0 | Write-Output } }
PowerShellCorpus/PowerShellGallery/PoshSequence/1.0.0.3/public/Save-SQSequences.ps1
Save-SQSequences.ps1
Function Save-SQSequences { [CmdletBinding()] Param([Parameter(Mandatory=$true)] [string]$Path) $script:sqsequences | ConvertTo-Json -Compress -Depth 100 | Set-Content -Path $path }
PowerShellCorpus/PowerShellGallery/cLCMCertManager/1.0.2/Examples/CertificateUpdate.ps1
CertificateUpdate.ps1
Configuration CertificateUpdate { cLCMCertUpdate CertUpdateBase { OutPath = $Node.OutPath OutputName = "Computer" TemplateName = "Lab Computer" } } $Nodes = @{ AllNodes = @( @{ PSDscAllowPlainTextPassword=$true NodeName = "SCCM01" OutPath = '\\DSC-0...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/Src/Import-ROWBuildingBlock.ps1
Import-ROWBuildingBlock.ps1
function Import-ROWBuildingBlock { <# .SYNOPSIS Imports a RES ONE Workspace building block. .EXAMPLE Import-ROWBuildingBlock -Path .\RESWM.xml Imports the 'RESWM.xml' building block into the RES ONE Workspace database using the current Windows user credentials. .EXA...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/Src/Export-ROWBuildingBlock.ps1
Export-ROWBuildingBlock.ps1
function Export-ROWBuildingBlock { <# .SYNOPSIS Exports a RES ONE Workspace building block. .EXAMPLE Export-ROWBuildingBlock -Path .\RESWM.xml Exports the entire RES ONE Workspace environment into the 'RESWM.xml' building block file. .EXAMPLE Export-ROWBuildingBlock...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Get-ROWErrorCode.ps1
Get-ROWErrorCode.ps1
function Get-ROWErrorCode { <# .SYNOPSIS Resolves a RES ONE Workspace console exit error code to a string. #> [CmdletBinding()] [OutputType([System.String])] param ( ## PWRTECH.EXE exit code to resolve to a string [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelin...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Get-ROWComponentInstallPath.ps1
Get-ROWComponentInstallPath.ps1
function Get-ROWComponentInstallPath { <# .SYNOPSIS Resolves the installation directory of the specified RES ONE Workspace component. #> [CmdletBinding()] [OutputType([System.String])] param ( [Parameter(Mandatory)] [ValidateSet('Agent','Console','RelayServer','Reporting...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Assert-ROWComponent.ps1
Assert-ROWComponent.ps1
function Assert-ROWComponent { <# .SYNOPSIS Ensures that the RES ONE Workspace component is installed. #> [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateSet('Agent','Console','RelayServer')] [System.String] $Component ) process { if (-...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Import-ROWBuildingBlockFile.ps1
Import-ROWBuildingBlockFile.ps1
function Import-ROWBuildingBlockFile { <# .SYNOPSIS Import a RES ONE Workspace building block. #> [CmdletBinding(DefaultParameterSetName = 'Path')] [OutputType([System.Management.Automation.PSCustomObject])] param ( # Specifies a path to one or more locations. Wildcards are permi...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Get-WindowsInstallerPackageProperty.ps1
Get-WindowsInstallerPackageProperty.ps1
function Get-WindowsInstallerPackageProperty { <# .SYNOPSIS This cmdlet retrieves product name from a Windows Installer MSI database. .DESCRIPTION This function uses the WindowInstaller COM object to pull all values from the Property table from a MSI package. .NOTES Adapted fr...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Start-WaitProcess.ps1
Start-WaitProcess.ps1
function Start-WaitProcess { <# .SYNOPSIS Starts and waits for a process to exit. .NOTES This is an internal function and shouldn't be called from outside. #> [CmdletBinding(SupportsShouldProcess)] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')] ...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Register-PInvoke.ps1
Register-PInvoke.ps1
function Register-PInvoke { <# .NOTES Kindly donated by Micorsoft from: https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/564bfba5bb0114623a334e1c7a8842b4996e05a6/DSCResources/MSFT_xPackageResource/MSFT_xPackageResource.psm1 #> [CmdletBinding()] param ( ) process { ...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Get-ROWConsolePath.ps1
Get-ROWConsolePath.ps1
function Get-ROWConsolePath { <# .SYNOPSIS Returns the RES ONE Workspace console path. #> [CmdletBinding()] [OutputType([System.String])] param ( ) begin { Assert-ROWComponent -Component 'Console'; } process { $pwrtechRootPath = Get-ROWComponentInsta...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Export-ROWBuildingBlockFile.ps1
Export-ROWBuildingBlockFile.ps1
function Export-ROWBuildingBlockFile { <# .SYNOPSIS Exports a RES ONE Workspace building block. .EXAMPLE Export-ROWBuildingBlock -Path .\RESWM.xml Exports the entire RES ONE Workspace environment into the 'RESWM.xml' building block file. .EXAMPLE Export-ROWBuildingB...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Get-InstalledProductEntry.ps1
Get-InstalledProductEntry.ps1
function Get-InstalledProductEntry { <# .NOTES https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/dev/DSCResources/MSFT_xPackageResource/MSFT_xPackageResource.psm1 #> [CmdletBinding()] param ( [Parameter()] [ValidateNotNullOrEmpty()] [System.String] $Nam...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Get-RegistryValueIgnoreError.ps1
Get-RegistryValueIgnoreError.ps1
function Get-RegistryValueIgnoreError { <# .NOTES https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/dev/DSCResources/MSFT_xPackageResource/MSFT_xPackageResource.psm1 #> param ( [Parameter(Mandatory)] [Microsoft.Win32.RegistryHive] $RegistryHive, [Paramet...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Get-LocalizableRegistryKeyValue.ps1
Get-LocalizableRegistryKeyValue.ps1
function Get-LocalizableRegistryKeyValue { <# .NOTES https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/dev/DSCResources/MSFT_xPackageResource/MSFT_xPackageResource.psm1 #> [CmdletBinding()] param ( [Parameter()] [System.Object] $RegistryKey, [Paramete...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/DSCResources/ROWCommon/Src/Resolve-ROWPackagePath.ps1
Resolve-ROWPackagePath.ps1
function Resolve-ROWPackagePath { <# .SYNOPSIS Resolves the latest RES ONE Workspace/Workspace Manager installation package. #> [CmdletBinding()] param ( ## The literal file path or root search path [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [System.S...
PowerShellCorpus/PowerShellGallery/RESONEWorkspace/2.2.3/Examples/RESONEWorkspaceLabExample.ps1
RESONEWorkspaceLabExample.ps1
$config = @{ AllNodes = @( @{ NodeName = 'localhost'; PSDSCAllowPlainTextPassword = $true; ROWDatabaseServer = 'controller.lab.local'; ROWDatabaseName = 'RESONEWorkspace'; ROWBinariesFolder = 'C:\SharedData\Software\RES\ONE Worksapce ...
PowerShellCorpus/PowerShellGallery/ESAE/0.0.0.22/ESAE.ps1
ESAE.ps1
# # This is a PowerShell Unit Test file. # You need a unit test framework such as Pester to run PowerShell Unit tests. # You can download Pester from http://go.microsoft.com/fwlink/?LinkID=534084 # Describe "Get-Function" { Context "Function Exists" { It "Should Return" { } } }
PowerShellCorpus/PowerShellGallery/xSCVMM/1.2.4.0/Examples/SCVMM-SeperateSQL-TP.ps1
SCVMM-SeperateSQL-TP.ps1
#requires -Version 5 Configuration VMM { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($AllNodes.Where{$_.Roles | Where-Object {...
PowerShellCorpus/PowerShellGallery/xSCVMM/1.2.4.0/Examples/SCVMM-SingleServer.ps1
SCVMM-SingleServer.ps1
#requires -Version 5 Configuration VMM { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($AllNodes.Where{$_.Roles | Where-Object {...
PowerShellCorpus/PowerShellGallery/xSCVMM/1.2.4.0/Examples/SCVMM-SeperateSQL.ps1
SCVMM-SeperateSQL.ps1
#requires -Version 5 Configuration VMM { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($AllNodes.Where{$_.Roles | Where-Object {...
PowerShellCorpus/PowerShellGallery/xSCVMM/1.2.4.0/Examples/SCVMM-SingleServer-TP.ps1
SCVMM-SingleServer-TP.ps1
#requires -Version 5 Configuration VMM { Import-DscResource -Module xSQLServer Import-DscResource -Module xSCVMM # Set role and instance variables $Roles = $AllNodes.Roles | Sort-Object -Unique foreach($Role in $Roles) { $Servers = @($AllNodes.Where{$_.Roles | Where-Object {...
PowerShellCorpus/PowerShellGallery/MemoryTools/0.4.1/MemoryToolsSettings.ps1
MemoryToolsSettings.ps1
#global settings for MemoryTools commands <# These are variables that will be used with Get-MemoryUsage to determine the status. The value is a percentage of free physical memory available. Any detected value less than $MemoryToolsWarning will be classified as Critical. You can change these variables at an...
PowerShellCorpus/PowerShellGallery/MemoryTools/0.4.1/Tests/MemoryTools.tests.ps1
MemoryTools.tests.ps1
#Pester Tests #Show-MemoryUsage can't be tested because it doesn't write anything to the pipeline Import-Module ..\MemoryTools inModuleScope MemoryTools { #create a sample object like something imported from a CSV file #or other command $computerObject = New-object -typename PSObject -property @{ ...
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Pester.Tests.ps1
Pester.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $manifestPath = (Join-Path $here 'Pester.psd1') $changeLogPath = (Join-Path $here 'CHANGELOG.md') # DO NOT CHANGE THIS TAG NAME; IT AFFECTS THE CI BUILD. Describe -Tags 'VersionChecks' "Pester manifest and changelog" { $script:manifest = $null ...
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Examples/Validator/Validator.Steps.ps1
Validator.Steps.ps1
$global:ValidatorRoot = Split-Path $MyInvocation.MyCommand.Path BeforeEachFeature { New-Module -Name ValidatorTest { . $global:ValidatorRoot\Validator.ps1 -Verbose } | Import-Module -Global } AfterEachFeature { Remove-Module ValidatorTest } Given 'MyValidator is mocked to return True'...
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Examples/Validator/Validator.ps1
Validator.ps1
function MyValidator($thing_to_validate) { return $thing_to_validate.StartsWith("s") } function Invoke-SomethingThatUsesMyValidator { param( [ValidateScript({MyValidator $_})] $some_param ) }
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Examples/Validator/Validator.Tests.ps1
Validator.Tests.ps1
$scriptRoot = Split-Path $MyInvocation.MyCommand.Path . $scriptRoot\Validator.ps1 -Verbose Describe "Testing a validator" { It "calls MyValidator" { Mock MyValidator -MockWith { return $true } Invoke-SomethingThatUsesMyValidator "test" $was_called_once = 1 Assert-MockCalle...
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Examples/Calculator/Add-Numbers.ps1
Add-Numbers.ps1
function Add-Numbers($a, $b) { return $a + $b }
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/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/PowerShellGallery/Pester/4.0.3/Examples/Gherkin/VariableScope.Steps.ps1
VariableScope.Steps.ps1
When 'I (?:set|initialize) the variable (?<Name>[\w:]+) to "(?<Value>[^"]+)"' { param($Name, $Value) switch($Name) { "One" { $One = $Value } "Two" { $Two = $Value } "Script:Two" { $Script:Two = $Value } } } Given 'I initialize variables One and (?<Script>.+:)?Two to ...
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/It.Tests.ps1
It.Tests.ps1
Set-StrictMode -Version Latest InModuleScope Pester { Describe 'It - Implementation' { $testState = New-PesterState -Path $TestDrive It 'Throws an error if you fail to pass in a test block' { $scriptBlock = { ItImpl -Pester $testState 'Some Name' } $scriptBlock | ...
PowerShellCorpus/PowerShellGallery/Pester/4.0.3/Functions/Gherkin.ps1
Gherkin.ps1
# Work around bug in PowerShell 2 type loading... Microsoft.PowerShell.Core\Import-Module -Name "${Script:PesterRoot}\lib\Gherkin.dll" $StepPrefix = "Gherkin-Step " $GherkinSteps = @{} $GherkinHooks = @{ BeforeEachFeature = @() BeforeEachScenario = @() AfterEachFeature = @()...