├── .gitignore
├── Build.ps1
├── Examples
├── Basic-Cleanup.ps1
├── Basic-Example.ps1
└── Basic-Script.ps1
├── LICENSE
├── README.md
├── Source
├── Functions
│ ├── Install-ScriptAsService.ps1
│ ├── New-ScriptAsService.ps1
│ ├── Set-ScriptAsServiceCredential.ps1
│ └── Uninstall-ScriptAsService.ps1
├── ScriptAsService.psd1
└── ScriptAsService.psm1
├── libraries
└── Sorlov.PowerShell
│ ├── Sorlov.PowerShell.Core.dll
│ ├── Sorlov.PowerShell.Core.dll-help.xml
│ ├── Sorlov.PowerShell.Core.psd1
│ ├── Sorlov.PowerShell.Format.ps1xml
│ ├── Sorlov.PowerShell.SelfHosted.dll
│ ├── Sorlov.PowerShell.SelfHosted.dll-help.xml
│ └── Sorlov.PowerShell.Types.ps1xml
└── psake.ps1
/.gitignore:
--------------------------------------------------------------------------------
1 | TestResults*
2 | ScriptAsService
--------------------------------------------------------------------------------
/Build.ps1:
--------------------------------------------------------------------------------
1 | [cmdletbinding()]
2 | Param (
3 | [string]$ApiKey,
4 | [string[]]$TaskList
5 | )
6 |
7 | ForEach ($Module in @("Pester","Psake","BuildHelpers")) {
8 | If (!(Get-Module -ListAvailable $Module)) {
9 | Find-Module $Module | Install-Module -Force
10 | }
11 | Import-Module $Module
12 | }
13 |
14 | Push-Location $PSScriptRoot
15 | Write-Output "Retrieving Build Variables"
16 | Get-ChildItem -Path env:\bh* | Remove-Item
17 | Set-BuildEnvironment
18 | $null = New-Item -Path ENV:\APIKEY -Value $ApiKey
19 |
20 | If ($TaskList.Count -gt 0) {
21 | Write-Output "Executing Tasks: $TaskList`r`n"
22 | Invoke-Psake -buildFile .\psake.ps1 -properties $PSBoundParameters -noLogo -taskList $TaskList
23 | } Else {
24 | Write-Output "Executing Unit Tests Only`r`n"
25 | Invoke-Psake -buildFile .\psake.ps1 -properties $PSBoundParameters -nologo
26 | }
27 |
--------------------------------------------------------------------------------
/Examples/Basic-Cleanup.ps1:
--------------------------------------------------------------------------------
1 | #requires -Modules ScriptAsService
2 | #requires -RunAsAdministrator
3 | Uninstall-ScriptAsService -Name "basic_example"
4 | Remove-Item -Path "$env:USERPROFILE\Temp-Basic-Example-Script-As-Service" -Recurse -Force
5 |
--------------------------------------------------------------------------------
/Examples/Basic-Example.ps1:
--------------------------------------------------------------------------------
1 | #requires -Modules ScriptAsService
2 | #requires -RunAsAdministrator
3 |
4 | $SourceFile = "$PSScriptRoot\Basic-Script.ps1"
5 | $BaseFolder = "$env:USERPROFILE\Temp-Basic-Example-Script-As-Service"
6 | $ScriptFile = "$BaseFolder\Basic.ps1"
7 | $OutputFile = "$BaseFolder\basic.exe"
8 | $ServiceName = "basic_example"
9 | $ServiceDisplayName = "Basic Example of a Script As Service"
10 | $ServiceDescription = "A basic example of PowerShell script as service; simply creates a file in your downloads file and updates it continuously."
11 |
12 | Try {
13 | If (-not (Test-Path $BaseFolder)){
14 | New-Item -Path $BaseFolder -ItemType Directory -Force
15 | (Get-Content -Path $SourceFile).Replace("_ENVUSERNAME_",$env:USERNAME) | Out-File -FilePath $ScriptFile
16 | }
17 | New-ScriptAsService -Path $ScriptFile -Destination $OutputFile -Name $ServiceName -DisplayName $ServiceDisplayName -Description $ServiceDescription -ErrorAction Stop
18 | Install-ScriptAsService -Path $OutputFile -Name $ServiceName -Description $ServiceDescription -ErrorAction Stop
19 | Do {
20 | Start-Sleep -Seconds 10
21 | Get-Content -Path "$BaseFolder\_TestService.txt"
22 | Write-Host "`r`nYou've just checked the file. It should write a new log every ten seconds."
23 | $Response = Read-Host "Do you want to continue checking the file? (y)es or (n)o?"
24 | If($Response -in @('n','N','no','No')){
25 | $Continue = $false
26 | } Else {
27 | $Continue = $true
28 | }
29 | } While ($Continue -eq $true)
30 | } Catch {
31 | Throw $_
32 | }
33 |
--------------------------------------------------------------------------------
/Examples/Basic-Script.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Test .ps1 script to be used as a Windows Service.
4 |
5 | .DESCRIPTION
6 | Save as .ps1 and run.
7 | Script creates a file "%USERPROFILE%\Downloads\_TestService.txt" in the current users Downloads Folder
8 | Every 10 seconds from the time it is started, it will add the date to the above file.
9 |
10 | #>
11 | Remove-Variable -Name firstLoop -Force -EA SilentlyContinue -WA SilentlyContinue | Out-Null
12 | for($go = 1; $go -lt 2) # $go will always be less than 2, so this script will run until user intervention
13 | {
14 | $d = Get-Date
15 | $p = "C:\users\_ENVUSERNAME_\Temp-Basic-Example-Script-As-Service\_TestService.txt"
16 | if(Test-Path $p)
17 | {
18 | if($firstLoop -ne $false)
19 | {
20 | Add-Content -Value "$($d) - Script Started" -Path $p -EA SilentlyContinue -WA SilentlyContinue
21 | $firstLoop = $false
22 | }
23 | else
24 | {
25 | Add-Content -Value $d -Path $p -EA SilentlyContinue -WA SilentlyContinue
26 | }
27 | }
28 |
29 | if(!(Test-Path $p))
30 | {
31 | New-Item -Path $p -ItemType File -EA SilentlyContinue -WA SilentlyContinue | Out-Null
32 | if($firstLoop -ne $false)
33 | {
34 | Add-Content -Value "$($d) - Script Started" -Path $p -EA SilentlyContinue -WA SilentlyContinue
35 | $firstLoop = $false
36 | }
37 | else
38 | {
39 | Add-Content -Value $d -Path $p -EA SilentlyContinue -WA SilentlyContinue
40 | }
41 | }
42 | Start-Sleep -Seconds 10
43 | }
44 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Matt Oestreich (@oze41998), Michael T Lombardi (@michaeltlombardi)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ScriptAsService
2 | Turn any looping .ps1 script into a Windows Service With the help of the included Sorlov Assemblies (https://twitter.com/sorlov/status/515149451691044864).
3 |
4 | THANK YOU DANIEL SORLOV!
5 |
6 | ## Installation
7 | To install this module, simply run:
8 | ```powershell
9 | Install-Module -Name ScriptAsService
10 | ```
11 |
12 | ## Example
13 | For an example of how to use the module, clone the project locally and open an elevated PowerShell Prompt in the cloned folder (or `cd` into the cloned folder once you've opened PowerShell):
14 |
15 | ```powershell
16 | .\Examples\Basic-Example.ps1
17 | ```
18 |
19 | This will create an executable, install it as a service, and verify the output.
20 | Essentially, the service will just write the current time to a log file every ten seconds.
21 |
22 | To clean up after the example, run the following from the same prompt:
23 |
24 | ```powershell
25 | .\Examples\Basic-Cleanup.ps1
26 | ```
27 |
28 | ## Build Locally From Source
29 | Once you've cloned this project, open a PowerShell prompt and set the root folder of this project as your current directory. Then:
30 |
31 | ```powershell
32 | Invoke-Psake -buildFile .\psake.ps1 -taskList Build
33 | ```
34 |
35 | This will build a folder, `ScriptAsService` in the current directory.
36 | In that folder is a versioned folder containing the module.
37 | You should be able to copy this folder to your Module Path if you want, or import the module via path.
38 |
--------------------------------------------------------------------------------
/Source/Functions/Install-ScriptAsService.ps1:
--------------------------------------------------------------------------------
1 | Function Install-ScriptAsService {
2 | <#
3 | .SYNOPSIS
4 | Installs a script-as-service binary to the local computer.
5 |
6 | .DESCRIPTION
7 | Installs a script-as-service binary to the local computer.
8 |
9 | .PARAMETER Path
10 | The full or relative path to the binary file which should be run as a service.
11 |
12 | .PARAMETER Name
13 | The short, terse, unique name of the service - this **CAN NOT** have any spaces in it.
14 |
15 | .PARAMETER Description
16 | The description of the service you are creating. You can, optionally, leave this null.
17 |
18 | .PARAMETER Credential
19 | The credential (username and password) under which the service should run.
20 | It is preferable to set this to an account with minimal required permissions or managed service account.
21 |
22 | .EXAMPLE
23 | Install-ScripptAsService -Path C:\Project\Out\project.exe -Name Project -DisplayName 'Scheduled Project' -Credential $Cred
24 |
25 | This command installs a looping scriptp as a service from the specified path and with the specified name and display name.
26 |
27 | #>
28 | [CmdletBinding()]
29 | Param (
30 | [Parameter(Mandatory=$true,
31 | HelpMessage="Type the path (full or relative) to the script-as-service binary you want to install; make sure to include the file name and extension.")]
32 | [ValidateScript({Test-Path -Path $_})]
33 | [Alias("FilePath","SourceFilePath","ScriptPath")]
34 | [string]$Path,
35 | [Parameter(Mandatory=$true,
36 | HelpMessage="Type the SERVICE NAME [[ this is NOT the display name! ]] `r`nService Name must not contain spaces!")]
37 | [Alias("ServiceName")]
38 | [string]$Name,
39 | [Parameter(Mandatory=$true,
40 | HelpMessage="Type the desired service description.")]
41 | [Alias("SvcDescription","ServiceDescription")]
42 | [string]$Description,
43 | [Management.Automation.PSCredential]$Credential
44 | )
45 |
46 | [string]$RegistryPath = "HKLM:\SYSTEM\CurrentControlSet\Services\$Name"
47 | [string]$RegistryName = 'Description'
48 | [string]$RegistryValue = $Description
49 |
50 | Try {
51 | $ErrorActionPreferenceHolder = $ErrorActionPreference
52 | $ErrorActionPreference = "Stop"
53 | Start-Process -FilePath $Path -ArgumentList "/install" -Wait -WindowStyle Hidden
54 | $null = New-ItemProperty -Path $RegistryPath -Name $RegistryName -Value $RegistryValue -PropertyType String -Force
55 | If ($Credential) {
56 | $null = Set-ServiceCredential -ServiceName $Name -ServiceCredential $Credential
57 | }
58 | $null = Set-Service -Name $Name -StartupType Automatic
59 | $null = Start-Service -Name $Name
60 | Get-Service -Name $Name
61 | $ErrorActionPreference = $ErrorActionPreferenceHolder
62 | } Catch {
63 | Throw $_
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Source/Functions/New-ScriptAsService.ps1:
--------------------------------------------------------------------------------
1 | Function New-ScriptAsService {
2 | <#
3 | .SYNOPSIS
4 | Creates a Windows Service via .ps1 script.
5 |
6 | .DESCRIPTION
7 | This script is designed to convert at .ps1 looping script into a Windows Service legible binary file (aka .exe).
8 |
9 | The script **must** include the looping logic inside itself or the service will fail to run properly.
10 |
11 | You _must_ include the path to the script which is to be turned into a service, the destination path for the binary,
12 | the name of the service, and the display name of the service.
13 |
14 | You _can_, optionally, sign your binaries with a code-signing cert and timestamp url.
15 | You can also give the new binary an icon.
16 |
17 | .PARAMETER Path
18 | The full or relative path to the script file which should be run as a service.
19 |
20 | .PARAMETER Destination
21 | The full or relative path you want the binary to be output to.
22 | Note that this must include the name and extension of the binary (`C:\Some\Path\foo.exe`) whether you specify a full or relative path.
23 |
24 | .PARAMETER Name
25 | The short, terse, unique name of the service - this **CAN NOT** have any spaces in it.
26 |
27 | .PARAMETER DisplayName
28 | The display name of the service - something human readable and friendly.
29 | This _can_ include spaces.
30 |
31 | .PARAMETER Description
32 | The description of the service you are creating. You can, optionally, leave this null.
33 |
34 | .PARAMETER IconFilePath
35 | The full or relative path to the icon you want to set for the new service.
36 | This is optional.
37 |
38 | .PARAMETER Version
39 | The version you want the binary output to have - if you do not specify one, the version defaults to 1.0.0.
40 | Must be a valid [Semantic Version](semver.org).
41 |
42 | .EXAMPLE
43 | New-ScriptAsService -Path .\Project\project.ps1 -Name Project -DisplayName 'Looping Project'
44 |
45 | This will create a script-as-service binary, called `project.exe`, which when installed as a service
46 | will have a name of `Project` and a display name of `Looping Project`. The description will be empty
47 | and the version will be `1.0.0`.
48 |
49 | .PARAMETER SigningCertificatePath
50 | The full or relative path to the certificate you want to use for signing your binary.
51 | Must be a cert valid for code signing.
52 | This is an optional parameter.
53 |
54 | .PARAMETER TimeStampUrl
55 | If you are signing your binary, you probably also want to provide a timestamp url.
56 | Otherwise, do not include this parameter.
57 |
58 | #>
59 | [CmdletBinding()]
60 | Param (
61 | [Parameter(Mandatory=$true,
62 | HelpMessage="Type the path (full or relative) to the Script you want to turn into a service; make sure to include the file name and extension.")]
63 | [ValidateScript({Test-Path -Path $_})]
64 | [Alias("FilePath","SourceFilePath","ScriptPath")]
65 | [string]$Path,
66 |
67 | [Parameter(Mandatory=$true,
68 | HelpMessage="Type the path (full or relative) to where you want the service executable to be placed; make sure to include the file name and '.exe' extension.")]
69 | [Alias("OutputFilePath","DestinationPath","BinaryPath")]
70 | [string]$Destination,
71 |
72 | [Parameter(Mandatory=$true,
73 | HelpMessage="Type the desired SERVICE NAME [[ this is NOT the display name! ]] `r`nService Name must not contain spaces!")]
74 | [Alias("SvcName","ServiceName")]
75 | [string]$Name,
76 |
77 | [Parameter(Mandatory=$true,
78 | HelpMessage="Type the desired service DISPLAY name.")]
79 | [Alias("SvcDisplayName","ServiceDisplayName")]
80 | [string]$DisplayName,
81 |
82 | [Alias("SvcDescription","ServiceDescription")]
83 | [string]$Description = " ",
84 |
85 | [ValidateScript({Test-Path -Path $_})]
86 | [Alias("IconPath","Icon")]
87 | [string]$IconFilePath,
88 |
89 | [version]$Version = "1.0.0",
90 |
91 | [ValidateScript({Test-Path -Path $_})]
92 | [Alias("CertificatePath","Certificate","CertPath","Cert")]
93 | [string]$SigningCertificatePath,
94 |
95 | [string]$TimeStampUrl
96 | )
97 |
98 | $ServiceParameters = @{
99 | SourceFile = $Path
100 | DestinationFile = $Destination
101 | Service = $true
102 | ServiceDescription = $Description
103 | ServiceName = $Name
104 | ServiceDisplayName = $DisplayName
105 | Version = [string]$Version
106 | }
107 |
108 | If (-not [string]::IsNullOrEmpty($SigningCertificatePath)){
109 | $null = $ServiceParameters.Add("Sign",$true)
110 | $null = $ServiceParameters.Add("Certificate",$SigningCertificatePath)
111 | If (-not [string]::IsNullOrEmpty($TimeStampUrl)){
112 | $null = $ServiceParameters.Add("TimeStampURL",$TimeStampUrl)
113 | }
114 | }
115 | If (-not [string]::IsNullOrEmpty($IconFilePath)){
116 | $null = $ServiceParameters.Add("IconPath",$IconFilePath)
117 | }
118 | New-SelfHostedPS @ServiceParameters
119 | }
120 |
--------------------------------------------------------------------------------
/Source/Functions/Set-ScriptAsServiceCredential.ps1:
--------------------------------------------------------------------------------
1 | function Set-ScriptAsServiceCredential {
2 |
3 | <#
4 | .SYNOPSIS
5 | Set the Credential of an installed service.
6 |
7 | .DESCRIPTION
8 | Set or update the credential of an installed service programmatically.
9 | Sometimes this is required because the username/password of the account has expired or because a new account should be used.
10 |
11 | .PARAMETER Name
12 | The short, terse, unique name of the service - this **CAN NOT** have any spaces in it.
13 |
14 | .PARAMETER Credential
15 | The credential under which the service is being set to run.
16 |
17 | .PARAMETER ComputerName
18 | The ComputerName on which the service is to be updated.
19 | By default, this command executes against the localmachine.
20 |
21 | .EXAMPLE
22 | Set-ScriptAsServiceCredential -Name MyProject -Credential (Get-Credential SomeAccount)
23 |
24 | This command will ask for the credentials for `SomeAccount` and then set the service `MyProject`
25 | to run under `SomeAccount` using the specified credentials.
26 |
27 | #>
28 | [cmdletbinding()]
29 | param(
30 | [String[]]$Name,
31 | [Management.Automation.PSCredential]$Credential,
32 | [string]$ComputerName = $env:COMPUTERNAME
33 | )
34 |
35 | $ServiceQueryParameters = @{
36 | "Namespace" = "root\CIMV2"
37 | "Class" = "Win32_Service"
38 | "ComputerName" = $ComputerName
39 | "Filter" = "Name='$Name' OR DisplayName='$Name'"
40 | }
41 | $Service = Get-WmiObject @ServiceQueryParameters
42 |
43 | if ( -not $Service ) {
44 | Write-Error "Unable to find service named '$ServiceName' on '$ComputerName'."
45 | } else {
46 | # See https://msdn.microsoft.com/en-us/library/aa384901.aspx
47 | $returnValue = ($Service.Change($null, # DisplayName
48 | $null, # PathName
49 | $null, # ServiceType
50 | $null, # ErrorControl
51 | $null, # StartMode
52 | $null, # DesktopInteract
53 | $ServiceCredential.UserName, # StartName
54 | $ServiceCredential.GetNetworkCredential().Password, # StartPassword
55 | $null, # LoadOrderGroup
56 | $null, # LoadOrderGroupDependencies
57 | $null)).ReturnValue # ServiceDependencies
58 | $ErrorMessage = "Error setting credentials for service '$ServiceName' on '$ComputerName'"
59 | switch ( $returnValue ) {
60 | 0 { Write-Verbose "Set credentials for service '$ServiceName' on '$ComputerName'" }
61 | 1 { Write-Error "$ErrorMessage - Not Supported" }
62 | 2 { Write-Error "$ErrorMessage - Access Denied" }
63 | 3 { Write-Error "$ErrorMessage - Dependent Services Running" }
64 | 4 { Write-Error "$ErrorMessage - Invalid Service Control" }
65 | 5 { Write-Error "$ErrorMessage - Service Cannot Accept Control" }
66 | 6 { Write-Error "$ErrorMessage - Service Not Active" }
67 | 7 { Write-Error "$ErrorMessage - Service Request timeout" }
68 | 8 { Write-Error "$ErrorMessage - Unknown Failure" }
69 | 9 { Write-Error "$ErrorMessage - Path Not Found" }
70 | 10 { Write-Error "$ErrorMessage - Service Already Stopped" }
71 | 11 { Write-Error "$ErrorMessage - Service Database Locked" }
72 | 12 { Write-Error "$ErrorMessage - Service Dependency Deleted" }
73 | 13 { Write-Error "$ErrorMessage - Service Dependency Failure" }
74 | 14 { Write-Error "$ErrorMessage - Service Disabled" }
75 | 15 { Write-Error "$ErrorMessage - Service Logon Failed" }
76 | 16 { Write-Error "$ErrorMessage - Service Marked For Deletion" }
77 | 17 { Write-Error "$ErrorMessage - Service No Thread" }
78 | 18 { Write-Error "$ErrorMessage - Status Circular Dependency" }
79 | 19 { Write-Error "$ErrorMessage - Status Duplicate Name" }
80 | 20 { Write-Error "$ErrorMessage - Status Invalid Name" }
81 | 21 { Write-Error "$ErrorMessage - Status Invalid Parameter" }
82 | 22 { Write-Error "$ErrorMessage - Status Invalid Service Account" }
83 | 23 { Write-Error "$ErrorMessage - Status Service Exists" }
84 | 24 { Write-Error "$ErrorMessage - Service Already Paused" }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Source/Functions/Uninstall-ScriptAsService.ps1:
--------------------------------------------------------------------------------
1 | function Uninstall-ScriptAsService {
2 | <#
3 | .SYNOPSIS
4 | Uninstall a script-as-service binary
5 |
6 | .DESCRIPTION
7 | Uninstalls a script-as-service from one or more nodes.
8 |
9 | .PARAMETER Name
10 | The short, terse, unique name of the service - this **CAN NOT** have any spaces in it.
11 |
12 | .PARAMETER ComputerName
13 | The name of the computer or computers from which you want to uninstall the script-as-service
14 | binary. By default, the command targets the local machine.
15 |
16 | .EXAMPLE
17 | Uninstall-ScriptAsService -Name MyProject
18 |
19 | This command will uninstall the script-as-service binary whose service name is `MyProject`.
20 | #>
21 | Param(
22 | [Parameter( Mandatory = $true )]
23 | [string]$Name,
24 | [string[]]$ComputerName = $env:COMPUTERNAME
25 | )
26 |
27 | Try {
28 | $Service = Get-WmiObject -Class win32_service -ComputerName $ComputerName -ErrorAction Stop `
29 | | Where-Object -FilterScript {$_.Name -eq $Name} -ErrorAction Stop
30 | $null = $Service.StopService()
31 | $null = $Service.Delete()
32 | } Catch {
33 | Throw $_
34 | }
35 |
36 | $Service = Get-WmiObject -Class win32_service -ComputerName $ComputerName `
37 | | Where-Object -FilterScript {$_.Name -eq $Name}
38 |
39 | If (-not [string]::IsNullOrEmpty($Service)){
40 | Throw "Service not uninstalled!"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Source/ScriptAsService.psd1:
--------------------------------------------------------------------------------
1 | @{
2 |
3 | # Script module or binary module file associated with this manifest.
4 | RootModule = 'ScriptAsService'
5 |
6 | # Version number of this module.
7 | ModuleVersion = '0.1.0'
8 |
9 | # ID used to uniquely identify this module
10 | GUID = 'cb2f1c63-c802-49db-b6e4-0c18f736f0f9'
11 |
12 | # Author of this module
13 | Author = 'Matt Oestreich (@oze41998), Michael T Lombardi (@barbariankb)'
14 |
15 | # Company or vendor of this module
16 | CompanyName = ''
17 |
18 | # Copyright statement for this module
19 | Copyright = ''
20 |
21 | # Description of the functionality provided by this module
22 | Description = 'Functionality for turning PowerShell scripts into deployable binary services.'
23 |
24 | # Minimum version of the Windows PowerShell engine required by this module
25 | PowerShellVersion = '5.0'
26 |
27 | # Name of the Windows PowerShell host required by this module
28 | # PowerShellHostName = ''
29 |
30 | # Minimum version of the Windows PowerShell host required by this module
31 | # PowerShellHostVersion = ''
32 |
33 | # Minimum version of Microsoft .NET Framework required by this module
34 | # DotNetFrameworkVersion = ''
35 |
36 | # Minimum version of the common language runtime (CLR) required by this module
37 | # CLRVersion = ''
38 |
39 | # Processor architecture (None, X86, Amd64) required by this module
40 | # ProcessorArchitecture = ''
41 |
42 | # Modules that must be imported into the global environment prior to importing this module
43 | # RequiredModules = @()
44 |
45 | # Assemblies that must be loaded prior to importing this module
46 | # RequiredAssemblies = @()
47 |
48 | # Script files (.ps1) that are run in the caller's environment prior to importing this module.
49 | # ScriptsToProcess = @()
50 |
51 | # Type files (.ps1xml) to be loaded when importing this module
52 | # TypesToProcess = @()
53 |
54 | # Format files (.ps1xml) to be loaded when importing this module
55 | # FormatsToProcess = 'MaritzITServices.format.ps1xml'
56 |
57 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
58 | NestedModules = @()
59 |
60 | # Functions to export from this module
61 | FunctionsToExport = @(
62 | 'New-ScriptAsService',
63 | 'Install-ScriptAsService',
64 | 'Uninstall-ScriptAsService'
65 | )
66 |
67 | # Cmdlets to export from this module
68 | CmdletsToExport = ''
69 |
70 | # Variables to export from this module
71 | VariablesToExport = ''
72 |
73 | # Aliases to export from this module
74 | AliasesToExport = '*'
75 |
76 | # List of all modules packaged with this module
77 | ModuleList = @('ScriptAsService')
78 |
79 | # List of all files packaged with this module
80 | # FileList = @()
81 |
82 | # Private data to pass to the module specified in RootModule/ModuleToProcess
83 | # PrivateData = ''
84 |
85 | # HelpInfo URI of this module
86 | HelpInfoURI = 'https://mitsgallery.maritz.com/docs/ScriptAsService'
87 |
88 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
89 | # DefaultCommandPrefix = ''
90 |
91 | }
--------------------------------------------------------------------------------
/Source/ScriptAsService.psm1:
--------------------------------------------------------------------------------
1 | # Import Dependency Libraries
2 | $DependencyRoot = "$(Split-Path $PSScriptRoot -Parent)\Libraries\Sorlov.PowerShell"
3 | Import-Module "$DependencyRoot\Sorlov.PowerShell.Core.psd1"
4 | Import-Module "$DependencyRoot\Sorlov.PowerShell.SelfHosted.dll"
5 |
6 | Get-ChildItem "$PSScriptRoot\Functions" -Recurse |
7 | Where-Object -FilterScript {$_.FullName -match "\.ps1$" -and $_.FullName -notmatch "\.Tests\."} |
8 | ForEach-Object -Process {
9 | . $_.FullName
10 | }
11 |
12 | Export-ModuleMember -Function *
--------------------------------------------------------------------------------
/libraries/Sorlov.PowerShell/Sorlov.PowerShell.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewoestreich/New-PSService/5c737c0c0f949c869c0414e9c781a0575678814e/libraries/Sorlov.PowerShell/Sorlov.PowerShell.Core.dll
--------------------------------------------------------------------------------
/libraries/Sorlov.PowerShell/Sorlov.PowerShell.Core.dll-help.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Get-Assembly
5 |
6 | Returns a list of all loaded assemblies
7 |
8 |
9 | Copyright © 2013 Daniel Sörlöv
10 |
11 | Get
12 | Assembly
13 | 4.5.1.0
14 |
15 |
16 | Returns a list of all loaded assemblies
17 |
18 | Copyright © 2013 Daniel Sörlöv
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | For more information, type "Get-Help Get-Assembly -detailed". For technical information, type "Get-Help Get-Assembly -full".
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | Get-Quote
57 |
58 | Gets the daily qoute
59 |
60 |
61 | Copyright © 2013 Daniel Sörlöv
62 |
63 | Get
64 | Quote
65 | 4.5.1.0
66 |
67 |
68 | This cmdlet gets a qoute of the day
69 |
70 | Copyright © 2013 Daniel Sörlöv
71 |
72 |
73 |
74 | Get-Quote
75 |
76 | Display
77 | SwitchParameter
78 |
79 |
80 |
81 |
82 |
83 | Display
84 |
85 | Prints the message nice on screen
86 |
87 | SwitchParameter
88 |
89 | SwitchParameter
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | For more information, type "Get-Help Get-Quote -detailed". For technical information, type "Get-Help Get-Quote -full".
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | Get-NotifyIcon
133 |
134 | ¨Shows a tray icon and a message balloon
135 |
136 |
137 | Copyright © 2013 Daniel Sörlöv
138 |
139 | Get
140 | NotifyIcon
141 | 4.5.1.0
142 |
143 |
144 | Perfect for displaying information from background scripts.
145 |
146 | Copyright © 2013 Daniel Sörlöv
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 | For more information, type "Get-Help Get-NotifyIcon -detailed". For technical information, type "Get-Help Get-NotifyIcon -full".
177 |
178 |
179 |
180 |
181 | ------------------EXAMPLE 1-----------------------
182 | Show-Balloon $Message $Title Warning
183 |
184 | Shows the $Message and the title $Title using the warning icon
185 |
186 |
187 |
188 | ------------------EXAMPLE 2-----------------------
189 | Show-Balloon $Message
190 |
191 | Shows a message containing $Message in the taskbar of the computer
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 | Set-NotifyIcon
200 |
201 | ¨Shows a tray icon and a message balloon
202 |
203 |
204 | Copyright © 2013 Daniel Sörlöv
205 |
206 | Set
207 | NotifyIcon
208 | 4.5.1.0
209 |
210 |
211 | Perfect for displaying information from background scripts.
212 |
213 | Copyright © 2013 Daniel Sörlöv
214 |
215 |
216 |
217 | Set-NotifyIcon
218 |
219 | Name
220 | String
221 |
222 |
223 | TooltipText
224 | String
225 |
226 |
227 |
228 |
229 |
230 | Name
231 |
232 | The host or email to check
233 |
234 | String
235 |
236 | String
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 | TooltipText
245 |
246 | The host or email to check
247 |
248 | String
249 |
250 | String
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 | For more information, type "Get-Help Set-NotifyIcon -detailed". For technical information, type "Get-Help Set-NotifyIcon -full".
286 |
287 |
288 |
289 |
290 | ------------------EXAMPLE 1-----------------------
291 | Show-Balloon $Message $Title Warning
292 |
293 | Shows the $Message and the title $Title using the warning icon
294 |
295 |
296 |
297 | ------------------EXAMPLE 2-----------------------
298 | Show-Balloon $Message
299 |
300 | Shows a message containing $Message in the taskbar of the computer
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 | New-NotifyIcon
309 |
310 | ¨Shows a tray icon and a message balloon
311 |
312 |
313 | Copyright © 2013 Daniel Sörlöv
314 |
315 | New
316 | NotifyIcon
317 | 4.5.1.0
318 |
319 |
320 | Perfect for displaying information from background scripts.
321 |
322 | Copyright © 2013 Daniel Sörlöv
323 |
324 |
325 |
326 | New-NotifyIcon
327 |
328 | Name
329 | String
330 |
331 |
332 | TooltipText
333 | String
334 |
335 |
336 |
337 |
338 |
339 | Name
340 |
341 | The host or email to check
342 |
343 | String
344 |
345 | String
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 | TooltipText
354 |
355 | The host or email to check
356 |
357 | String
358 |
359 | String
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 | For more information, type "Get-Help New-NotifyIcon -detailed". For technical information, type "Get-Help New-NotifyIcon -full".
395 |
396 |
397 |
398 |
399 | ------------------EXAMPLE 1-----------------------
400 | Show-Balloon $Message $Title Warning
401 |
402 | Shows the $Message and the title $Title using the warning icon
403 |
404 |
405 |
406 | ------------------EXAMPLE 2-----------------------
407 | Show-Balloon $Message
408 |
409 | Shows a message containing $Message in the taskbar of the computer
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 | Remove-NotifyIcon
418 |
419 | ¨Shows a tray icon and a message balloon
420 |
421 |
422 | Copyright © 2013 Daniel Sörlöv
423 |
424 | Remove
425 | NotifyIcon
426 | 4.5.1.0
427 |
428 |
429 | Perfect for displaying information from background scripts.
430 |
431 | Copyright © 2013 Daniel Sörlöv
432 |
433 |
434 |
435 | Remove-NotifyIcon
436 |
437 | Name
438 | String
439 |
440 |
441 |
442 |
443 |
444 | Name
445 |
446 | The host or email to check
447 |
448 | String
449 |
450 | String
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 | For more information, type "Get-Help Remove-NotifyIcon -detailed". For technical information, type "Get-Help Remove-NotifyIcon -full".
486 |
487 |
488 |
489 |
490 | ------------------EXAMPLE 1-----------------------
491 | Show-Balloon $Message
492 |
493 | Shows a message containing $Message in the taskbar of the computer
494 |
495 |
496 |
497 | ------------------EXAMPLE 2-----------------------
498 | Show-Balloon $Message $Title Warning
499 |
500 | Shows the $Message and the title $Title using the warning icon
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 | Set-Window
509 |
510 | Gets the position of a windows form
511 |
512 |
513 | Copyright © 2013 Daniel Sörlöv
514 |
515 | Set
516 | Window
517 | 4.5.1.0
518 |
519 |
520 | Returns the current, or selected window, position
521 |
522 | Copyright © 2013 Daniel Sörlöv
523 |
524 |
525 |
526 | Set-Window
527 |
528 | WindowHandle
529 | IntPtr
530 |
531 |
532 | X
533 | Int32
534 |
535 |
536 | Y
537 | Int32
538 |
539 |
540 | Width
541 | Int32
542 |
543 |
544 | Height
545 | Int32
546 |
547 |
548 | State
549 | Normal | Minimized | Maximized
550 |
551 |
552 | Flash
553 | Stop | Infinite | Quick | Long
554 |
555 |
556 |
557 |
558 |
559 | WindowHandle
560 |
561 | The host or email to check
562 |
563 | IntPtr
564 |
565 | IntPtr
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 | X
574 |
575 | The host or email to check
576 |
577 | Int32
578 |
579 | Int32
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 | Y
588 |
589 | The host or email to check
590 |
591 | Int32
592 |
593 | Int32
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 | Width
602 |
603 | The host or email to check
604 |
605 | Int32
606 |
607 | Int32
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 | Height
616 |
617 | The host or email to check
618 |
619 | Int32
620 |
621 | Int32
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 | State
630 |
631 | The host or email to check
632 |
633 | WindowState
634 |
635 | WindowState
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 | Flash
644 |
645 | The host or email to check
646 |
647 | WindowFlash
648 |
649 | WindowFlash
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 | For more information, type "Get-Help Set-Window -detailed". For technical information, type "Get-Help Set-Window -full".
685 |
686 |
687 |
688 |
689 | ------------------EXAMPLE 1-----------------------
690 | Get-WindowPosition (Get-Process 'notepad.exe').MainWindowHandle
691 |
692 | Returns the window position for notepad
693 |
694 |
695 |
696 | ------------------EXAMPLE 2-----------------------
697 | Get-WindowPosition
698 |
699 | Returns the position for current powershell host
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 | Add-Assembly
708 |
709 | Load a assembly into domain
710 |
711 |
712 | Copyright © 2013 Daniel Sörlöv
713 |
714 | Add
715 | Assembly
716 | 4.5.1.0
717 |
718 |
719 | Loads a specified assembly into memory. This is permanent until you restart PowerShell. Equivivalent to loading a assembly by using reflection.
720 |
721 | Copyright © 2013 Daniel Sörlöv
722 |
723 |
724 |
725 | Add-Assembly
726 |
727 | AssemblyName
728 | String
729 |
730 |
731 | ByLocation
732 | SwitchParameter
733 |
734 |
735 |
736 |
737 |
738 | AssemblyName
739 |
740 | The name or path to assembly for load
741 |
742 | String
743 |
744 | String
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 | ByLocation
753 |
754 | Will load the assembly from a specific location (not GAC)
755 |
756 | SwitchParameter
757 |
758 | SwitchParameter
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 | For more information, type "Get-Help Add-Assembly -detailed". For technical information, type "Get-Help Add-Assembly -full".
794 |
795 |
796 |
797 |
798 | ------------------EXAMPLE 1-----------------------
799 | Add-Assembly c:\someassembly.dll -ByLocation
800 |
801 | Loads assembly from c:\someassembly.dll
802 |
803 |
804 |
805 | ------------------EXAMPLE 2-----------------------
806 | Add-Assembly System.Security
807 |
808 | Loads System.Security into memory from GAC
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 | Get-LatestVersion
817 |
818 | Load a assembly
819 |
820 |
821 | Copyright © 2013 Daniel Sörlöv
822 |
823 | Get
824 | LatestVersion
825 | 4.5.1.0
826 |
827 |
828 | Load a assembly
829 |
830 | Copyright © 2013 Daniel Sörlöv
831 |
832 |
833 |
834 | Get-LatestVersion
835 |
836 | ReleaseNotes
837 | SwitchParameter
838 |
839 |
840 | Force
841 | SwitchParameter
842 |
843 |
844 | NoPrompt
845 | SwitchParameter
846 |
847 |
848 | NoDownload
849 | SwitchParameter
850 |
851 |
852 |
853 |
854 |
855 | ReleaseNotes
856 |
857 | Return the release notes.
858 |
859 | SwitchParameter
860 |
861 | SwitchParameter
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 | Force
870 |
871 | Force update
872 |
873 | SwitchParameter
874 |
875 | SwitchParameter
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 | NoPrompt
884 |
885 | Do not prompt for updates
886 |
887 | SwitchParameter
888 |
889 | SwitchParameter
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 | NoDownload
898 |
899 | Prohibit download
900 |
901 | SwitchParameter
902 |
903 | SwitchParameter
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 | For more information, type "Get-Help Get-LatestVersion -detailed". For technical information, type "Get-Help Get-LatestVersion -full".
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 | Remove-Alias
947 |
948 | Removes a defined alias
949 |
950 |
951 | Copyright © 2013 Daniel Sörlöv
952 |
953 | Remove
954 | Alias
955 | 4.5.1.0
956 |
957 |
958 | Removes a defined alias
959 |
960 | Copyright © 2013 Daniel Sörlöv
961 |
962 |
963 |
964 | Remove-Alias
965 |
966 | AliasName
967 | String
968 |
969 |
970 |
971 |
972 |
973 | AliasName
974 |
975 | The assembly to load
976 |
977 | String
978 |
979 | String
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 | For more information, type "Get-Help Remove-Alias -detailed". For technical information, type "Get-Help Remove-Alias -full".
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 | Get-AdminStatus
1023 |
1024 | Returns a list of all loaded assemblies
1025 |
1026 |
1027 | Copyright © 2013 Daniel Sörlöv
1028 |
1029 | Get
1030 | AdminStatus
1031 | 4.5.1.0
1032 |
1033 |
1034 | Returns a list of all loaded assemblies
1035 |
1036 | Copyright © 2013 Daniel Sörlöv
1037 |
1038 |
1039 |
1040 | Get-AdminStatus
1041 |
1042 | Path
1043 | String
1044 |
1045 |
1046 |
1047 |
1048 |
1049 | Path
1050 |
1051 | The file or directory to touch
1052 |
1053 | String
1054 |
1055 | String
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 |
1089 |
1090 | For more information, type "Get-Help Get-AdminStatus -detailed". For technical information, type "Get-Help Get-AdminStatus -full".
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 | Restart-PowerShell
1099 |
1100 | Starts a new session and then kills this one
1101 |
1102 |
1103 | Copyright © 2013 Daniel Sörlöv
1104 |
1105 | Restart
1106 | PowerShell
1107 | 4.5.1.0
1108 |
1109 |
1110 | Starts a new session and then kills this one
1111 |
1112 | Copyright © 2013 Daniel Sörlöv
1113 |
1114 |
1115 |
1116 | Restart-PowerShell
1117 |
1118 | Path
1119 | String
1120 |
1121 |
1122 |
1123 |
1124 |
1125 | Path
1126 |
1127 | The file or directory to touch
1128 |
1129 | String
1130 |
1131 | String
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1161 |
1162 |
1163 |
1164 |
1165 |
1166 | For more information, type "Get-Help Restart-PowerShell -detailed". For technical information, type "Get-Help Restart-PowerShell -full".
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 | Invoke-Elevated
1175 |
1176 | Returns a list of all loaded assemblies
1177 |
1178 |
1179 | Copyright © 2013 Daniel Sörlöv
1180 |
1181 | Invoke
1182 | Elevated
1183 | 4.5.1.0
1184 |
1185 |
1186 | Returns a list of all loaded assemblies
1187 |
1188 | Copyright © 2013 Daniel Sörlöv
1189 |
1190 |
1191 |
1192 | Invoke-Elevated
1193 |
1194 | Path
1195 | String
1196 |
1197 |
1198 |
1199 |
1200 |
1201 | Path
1202 |
1203 | The file or directory to touch
1204 |
1205 | String
1206 |
1207 | String
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 | For more information, type "Get-Help Invoke-Elevated -detailed". For technical information, type "Get-Help Invoke-Elevated -full".
1243 |
1244 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 | Import-Assembly
1251 |
1252 | Returns a list of all loaded assemblies
1253 |
1254 |
1255 | Copyright © 2013 Daniel Sörlöv
1256 |
1257 | Import
1258 | Assembly
1259 | 4.5.1.0
1260 |
1261 |
1262 | Returns a list of all loaded assemblies
1263 |
1264 | Copyright © 2013 Daniel Sörlöv
1265 |
1266 |
1267 |
1268 | Import-Assembly
1269 |
1270 | Path
1271 | String
1272 |
1273 |
1274 |
1275 |
1276 |
1277 | Path
1278 |
1279 | The file or directory to touch
1280 |
1281 | String
1282 |
1283 | String
1284 |
1285 |
1286 |
1287 |
1288 |
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 |
1296 |
1297 |
1298 |
1299 |
1300 |
1301 |
1302 |
1303 |
1304 |
1305 |
1306 |
1307 |
1308 |
1309 |
1310 |
1311 |
1312 |
1313 |
1314 |
1315 |
1316 |
1317 |
1318 | For more information, type "Get-Help Import-Assembly -detailed". For technical information, type "Get-Help Import-Assembly -full".
1319 |
1320 |
1321 |
1322 |
1323 |
1324 |
1325 |
1326 | Exit-PSEnvironment
1327 |
1328 | Internal exit hook for the Sorlov.PowerShell environment
1329 |
1330 |
1331 | Copyright © 2013 Daniel Sörlöv
1332 |
1333 | Exit
1334 | PSEnvironment
1335 | 4.5.1.0
1336 |
1337 |
1338 | This command is mostly for internal use or to save the enviroment during a session
1339 |
1340 | Copyright © 2013 Daniel Sörlöv
1341 |
1342 |
1343 |
1344 | Exit-PSEnvironment
1345 |
1346 | Path
1347 | String
1348 |
1349 |
1350 |
1351 |
1352 |
1353 | Path
1354 |
1355 | The file or directory to touch
1356 |
1357 | String
1358 |
1359 | String
1360 |
1361 |
1362 |
1363 |
1364 |
1365 |
1366 |
1367 |
1368 |
1369 |
1370 |
1371 |
1372 |
1373 |
1374 |
1375 |
1376 |
1377 |
1378 |
1379 |
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1387 |
1388 |
1389 |
1390 |
1391 |
1392 |
1393 |
1394 | For more information, type "Get-Help Exit-PSEnvironment -detailed". For technical information, type "Get-Help Exit-PSEnvironment -full".
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
1402 | Block-Mutex
1403 |
1404 | Blocks a mutex or wait for it to be free
1405 |
1406 |
1407 | Copyright © 2013 Daniel Sörlöv
1408 |
1409 | Block
1410 | Mutex
1411 | 4.5.1.0
1412 |
1413 |
1414 | This commandlet reserves a mutex and returns or if the mutex is already reserved it waits for it to be released.
1415 |
1416 | Copyright © 2013 Daniel Sörlöv
1417 |
1418 |
1419 |
1420 | Block-Mutex
1421 |
1422 | Name
1423 | String
1424 |
1425 |
1426 |
1427 |
1428 |
1429 | Name
1430 |
1431 | The name of the mutex
1432 |
1433 | String
1434 |
1435 | String
1436 |
1437 |
1438 |
1439 |
1440 |
1441 |
1442 |
1443 |
1444 |
1445 |
1446 |
1447 |
1448 |
1449 |
1450 |
1451 |
1452 |
1453 |
1454 |
1455 |
1456 |
1457 |
1458 |
1459 |
1460 |
1461 |
1462 |
1463 |
1464 |
1465 |
1466 |
1467 |
1468 |
1469 |
1470 | For more information, type "Get-Help Block-Mutex -detailed". For technical information, type "Get-Help Block-Mutex -full".
1471 |
1472 |
1473 |
1474 |
1475 |
1476 |
1477 |
1478 | Invoke-ParalellForeach
1479 |
1480 | This function can be used to execute tasks in parallel.
1481 |
1482 |
1483 | Copyright © 2013 Daniel Sörlöv
1484 |
1485 | Invoke
1486 | ParalellForeach
1487 | 4.5.1.0
1488 |
1489 |
1490 | his function can be used to execute tasks in parallel with more than 5 parallel tasks at once. The number of parallel tasks can be defined by parameter. The input is accepted by defining it by using the -InputObject parameter which also accepts input from the pipeline.
1491 |
1492 | Copyright © 2013 Daniel Sörlöv
1493 |
1494 |
1495 |
1496 | Invoke-ParalellForeach
1497 |
1498 | InputObject
1499 | PSObject
1500 |
1501 |
1502 | MaxThreads
1503 | Int32
1504 |
1505 |
1506 |
1507 |
1508 |
1509 | InputObject
1510 |
1511 | The document to convert to PDF
1512 |
1513 | PSObject
1514 |
1515 | PSObject
1516 |
1517 |
1518 |
1519 |
1520 |
1521 |
1522 |
1523 | MaxThreads
1524 |
1525 | The document to convert to PDF
1526 |
1527 | Int32
1528 |
1529 | Int32
1530 |
1531 |
1532 |
1533 |
1534 |
1535 |
1536 |
1537 |
1538 |
1539 |
1540 |
1541 |
1542 |
1543 |
1544 |
1545 |
1546 |
1547 |
1548 |
1549 |
1550 |
1551 |
1552 |
1553 |
1554 |
1555 |
1556 |
1557 |
1558 |
1559 |
1560 |
1561 |
1562 |
1563 |
1564 | For more information, type "Get-Help Invoke-ParalellForeach -detailed". For technical information, type "Get-Help Invoke-ParalellForeach -full".
1565 |
1566 |
1567 |
1568 |
1569 | ------------------EXAMPLE 1-----------------------
1570 | ForEach-Parallel -InputObject (Get-ChildItem -Path "D:\Files") -MaxThreads 100 -ScriptBlock {Copy-Item -Path $_.FullName -Destination E:\Company\Files}
1571 |
1572 |
1573 |
1574 |
1575 |
1576 | ------------------EXAMPLE 2-----------------------
1577 | Get-ChildItem -Path D:\Files | ForEach-Parallel -MaxThreads 100 -ScriptBlock {Copy-Item -Path $_.FullName -Destination E:\Company\Files}
1578 |
1579 |
1580 |
1581 |
1582 |
1583 | ------------------EXAMPLE 3-----------------------
1584 | 1..500 | Foreach-Parallel -MaxThreads 20 -ScriptBlock {New-VM –Name VM$_ –MemoryStartupBytes 512MB}
1585 |
1586 |
1587 |
1588 |
1589 |
1590 |
1591 |
1592 |
1593 |
1594 | Unblock-Mutex
1595 |
1596 | Blocks a mutex or wait for it to be free
1597 |
1598 |
1599 | Copyright © 2013 Daniel Sörlöv
1600 |
1601 | Unblock
1602 | Mutex
1603 | 4.5.1.0
1604 |
1605 |
1606 | This commandlet reserves a mutex and returns or if the mutex is already reserved it waits for it to be released.
1607 |
1608 | Copyright © 2013 Daniel Sörlöv
1609 |
1610 |
1611 |
1612 | Unblock-Mutex
1613 |
1614 | Name
1615 | String
1616 |
1617 |
1618 |
1619 |
1620 |
1621 | Name
1622 |
1623 | The name of the mutex
1624 |
1625 | String
1626 |
1627 | String
1628 |
1629 |
1630 |
1631 |
1632 |
1633 |
1634 |
1635 |
1636 |
1637 |
1638 |
1639 |
1640 |
1641 |
1642 |
1643 |
1644 |
1645 |
1646 |
1647 |
1648 |
1649 |
1650 |
1651 |
1652 |
1653 |
1654 |
1655 |
1656 |
1657 |
1658 |
1659 |
1660 |
1661 |
1662 | For more information, type "Get-Help Unblock-Mutex -detailed". For technical information, type "Get-Help Unblock-Mutex -full".
1663 |
1664 |
1665 |
1666 |
1667 |
1668 |
1669 |
1670 | Set-DesktopColor
1671 |
1672 | Sets transparancy for the current or selected window
1673 |
1674 |
1675 | Copyright © 2013 Daniel Sörlöv
1676 |
1677 | Set
1678 | DesktopColor
1679 | 4.5.1.0
1680 |
1681 |
1682 | Sets transparancy for the current or selected window (Windows Vista & Windows 7 only)
1683 |
1684 | Copyright © 2013 Daniel Sörlöv
1685 |
1686 |
1687 |
1688 | Set-DesktopColor
1689 |
1690 | Color
1691 | Object
1692 |
1693 |
1694 |
1695 |
1696 |
1697 | Color
1698 |
1699 | A color to set
1700 |
1701 | Object
1702 |
1703 | Object
1704 |
1705 |
1706 |
1707 |
1708 |
1709 |
1710 |
1711 |
1712 |
1713 |
1714 |
1715 |
1716 |
1717 |
1718 |
1719 |
1720 |
1721 |
1722 |
1723 |
1724 |
1725 |
1726 |
1727 |
1728 |
1729 |
1730 |
1731 |
1732 |
1733 |
1734 |
1735 |
1736 |
1737 |
1738 | For more information, type "Get-Help Set-DesktopColor -detailed". For technical information, type "Get-Help Set-DesktopColor -full".
1739 |
1740 |
1741 |
1742 |
1743 |
1744 |
1745 |
1746 | Get-DesktopColor
1747 |
1748 | Get the color of the desktop
1749 |
1750 |
1751 | Copyright © 2013 Daniel Sörlöv
1752 |
1753 | Get
1754 | DesktopColor
1755 | 4.5.1.0
1756 |
1757 |
1758 | Get the color of the desktop
1759 |
1760 | Copyright © 2013 Daniel Sörlöv
1761 |
1762 |
1763 |
1764 | Get-DesktopColor
1765 |
1766 | AdvancedMode
1767 | SwitchParameter
1768 |
1769 |
1770 |
1771 |
1772 |
1773 | AdvancedMode
1774 |
1775 | The host or email to check
1776 |
1777 | SwitchParameter
1778 |
1779 | SwitchParameter
1780 |
1781 |
1782 |
1783 |
1784 |
1785 |
1786 |
1787 |
1788 |
1789 |
1790 |
1791 |
1792 |
1793 |
1794 |
1795 |
1796 |
1797 |
1798 |
1799 |
1800 |
1801 |
1802 |
1803 |
1804 |
1805 |
1806 |
1807 |
1808 |
1809 |
1810 |
1811 |
1812 |
1813 |
1814 | For more information, type "Get-Help Get-DesktopColor -detailed". For technical information, type "Get-Help Get-DesktopColor -full".
1815 |
1816 |
1817 |
1818 |
1819 |
1820 |
1821 |
1822 | Disable-WindowControlBox
1823 |
1824 | Disables the controlbox on the window
1825 |
1826 |
1827 | Copyright © 2013 Daniel Sörlöv
1828 |
1829 | Disable
1830 | WindowControlBox
1831 | 4.5.1.0
1832 |
1833 |
1834 | Disables the controlbox on the current, or other specified hWnd, window.
1835 |
1836 | Copyright © 2013 Daniel Sörlöv
1837 |
1838 |
1839 |
1840 | Disable-WindowControlBox
1841 |
1842 | WindowHandle
1843 | IntPtr
1844 |
1845 |
1846 |
1847 |
1848 |
1849 | WindowHandle
1850 |
1851 | The host or email to check
1852 |
1853 | IntPtr
1854 |
1855 | IntPtr
1856 |
1857 |
1858 |
1859 |
1860 |
1861 |
1862 |
1863 |
1864 |
1865 |
1866 |
1867 |
1868 |
1869 |
1870 |
1871 |
1872 |
1873 |
1874 |
1875 |
1876 |
1877 |
1878 |
1879 |
1880 |
1881 |
1882 |
1883 |
1884 |
1885 |
1886 |
1887 |
1888 |
1889 |
1890 | For more information, type "Get-Help Disable-WindowControlBox -detailed". For technical information, type "Get-Help Disable-WindowControlBox -full".
1891 |
1892 |
1893 |
1894 |
1895 | ------------------EXAMPLE 1-----------------------
1896 | Disable-WindowControlBox (Get-Process 'notepad.exe').MainWindowHandle
1897 |
1898 | Disables the controlbox on the notepad window
1899 |
1900 |
1901 |
1902 | ------------------EXAMPLE 2-----------------------
1903 | Disable-WindowControlBox
1904 |
1905 | Disables the controlbox on the current window
1906 |
1907 |
1908 |
1909 |
1910 |
1911 | Enable-WindowControlBox
1912 |
1913 |
1914 |
1915 |
1916 |
1917 |
1918 | Enable-WindowControlBox
1919 |
1920 | Enables the controlbox on the window
1921 |
1922 |
1923 | Copyright © 2013 Daniel Sörlöv
1924 |
1925 | Enable
1926 | WindowControlBox
1927 | 4.5.1.0
1928 |
1929 |
1930 | Enables the controlbox on the current, or other specified hWnd, window.
1931 |
1932 | Copyright © 2013 Daniel Sörlöv
1933 |
1934 |
1935 |
1936 | Enable-WindowControlBox
1937 |
1938 | WindowHandle
1939 | IntPtr
1940 |
1941 |
1942 |
1943 |
1944 |
1945 | WindowHandle
1946 |
1947 | The host or email to check
1948 |
1949 | IntPtr
1950 |
1951 | IntPtr
1952 |
1953 |
1954 |
1955 |
1956 |
1957 |
1958 |
1959 |
1960 |
1961 |
1962 |
1963 |
1964 |
1965 |
1966 |
1967 |
1968 |
1969 |
1970 |
1971 |
1972 |
1973 |
1974 |
1975 |
1976 |
1977 |
1978 |
1979 |
1980 |
1981 |
1982 |
1983 |
1984 |
1985 |
1986 | For more information, type "Get-Help Enable-WindowControlBox -detailed". For technical information, type "Get-Help Enable-WindowControlBox -full".
1987 |
1988 |
1989 |
1990 |
1991 | ------------------EXAMPLE 1-----------------------
1992 | Enable-WindowControlBox
1993 |
1994 | Enables the controlbox on the current window
1995 |
1996 |
1997 |
1998 | ------------------EXAMPLE 2-----------------------
1999 | Enable-WindowControlBox (Get-Process 'notepad.exe').MainWindowHandle
2000 |
2001 | Enables the controlbox on the notepad window
2002 |
2003 |
2004 |
2005 |
2006 |
2007 | Disable-WindowControlBox
2008 |
2009 |
2010 |
2011 |
2012 |
2013 |
2014 | Get-Window
2015 |
2016 | Gets the position of a windows form
2017 |
2018 |
2019 | Copyright © 2013 Daniel Sörlöv
2020 |
2021 | Get
2022 | Window
2023 | 4.5.1.0
2024 |
2025 |
2026 | Returns the current, or selected window, position
2027 |
2028 | Copyright © 2013 Daniel Sörlöv
2029 |
2030 |
2031 |
2032 | Get-Window
2033 |
2034 | WindowHandle
2035 | IntPtr
2036 |
2037 |
2038 |
2039 |
2040 |
2041 | WindowHandle
2042 |
2043 | The host or email to check
2044 |
2045 | IntPtr
2046 |
2047 | IntPtr
2048 |
2049 |
2050 |
2051 |
2052 |
2053 |
2054 |
2055 |
2056 |
2057 |
2058 |
2059 |
2060 |
2061 |
2062 |
2063 |
2064 |
2065 |
2066 |
2067 |
2068 |
2069 |
2070 |
2071 |
2072 |
2073 |
2074 |
2075 |
2076 |
2077 |
2078 |
2079 |
2080 |
2081 |
2082 | For more information, type "Get-Help Get-Window -detailed". For technical information, type "Get-Help Get-Window -full".
2083 |
2084 |
2085 |
2086 |
2087 | ------------------EXAMPLE 1-----------------------
2088 | Get-WindowPosition (Get-Process 'notepad.exe').MainWindowHandle
2089 |
2090 | Returns the window position for notepad
2091 |
2092 |
2093 |
2094 | ------------------EXAMPLE 2-----------------------
2095 | Get-WindowPosition
2096 |
2097 | Returns the position for current powershell host
2098 |
2099 |
2100 |
2101 |
2102 |
2103 |
2104 |
2105 | Set-WindowsTransparency
2106 |
2107 | Sets transparancy for the current or selected window
2108 |
2109 |
2110 | Copyright © 2013 Daniel Sörlöv
2111 |
2112 | Set
2113 | WindowsTransparency
2114 | 4.5.1.0
2115 |
2116 |
2117 | Sets transparancy for the current or selected window (Windows Vista & Windows 7 only)
2118 |
2119 | Copyright © 2013 Daniel Sörlöv
2120 |
2121 |
2122 |
2123 | Set-WindowsTransparency
2124 |
2125 | WindowHandle
2126 | IntPtr
2127 |
2128 |
2129 |
2130 |
2131 |
2132 | WindowHandle
2133 |
2134 | The host or email to check
2135 |
2136 | IntPtr
2137 |
2138 | IntPtr
2139 |
2140 |
2141 |
2142 |
2143 |
2144 |
2145 |
2146 |
2147 |
2148 |
2149 |
2150 |
2151 |
2152 |
2153 |
2154 |
2155 |
2156 |
2157 |
2158 |
2159 |
2160 |
2161 |
2162 |
2163 |
2164 |
2165 |
2166 |
2167 |
2168 |
2169 |
2170 |
2171 |
2172 |
2173 | For more information, type "Get-Help Set-WindowsTransparency -detailed". For technical information, type "Get-Help Set-WindowsTransparency -full".
2174 |
2175 |
2176 |
2177 |
2178 |
2179 |
2180 |
2181 | Show-Balloon
2182 |
2183 | ¨Shows a tray icon and a message balloon
2184 |
2185 |
2186 | Copyright © 2013 Daniel Sörlöv
2187 |
2188 | Show
2189 | Balloon
2190 | 4.5.1.0
2191 |
2192 |
2193 | Perfect for displaying information from background scripts.
2194 |
2195 | Copyright © 2013 Daniel Sörlöv
2196 |
2197 |
2198 |
2199 | Show-Balloon
2200 |
2201 | Message
2202 | String
2203 |
2204 |
2205 | Title
2206 | String
2207 |
2208 |
2209 | Icon
2210 | String
2211 |
2212 |
2213 | Duration
2214 | Int32
2215 |
2216 |
2217 | NotifyIconName
2218 | String
2219 |
2220 |
2221 |
2222 |
2223 |
2224 | Message
2225 |
2226 | The host or email to check
2227 |
2228 | String
2229 |
2230 | String
2231 |
2232 |
2233 |
2234 |
2235 |
2236 |
2237 |
2238 | Title
2239 |
2240 | The host or email to check
2241 |
2242 | String
2243 |
2244 | String
2245 |
2246 |
2247 |
2248 |
2249 |
2250 |
2251 |
2252 | Icon
2253 |
2254 | The host or email to check
2255 |
2256 | String
2257 |
2258 | String
2259 |
2260 |
2261 |
2262 |
2263 |
2264 |
2265 |
2266 | Duration
2267 |
2268 | The host or email to check
2269 |
2270 | Int32
2271 |
2272 | Int32
2273 |
2274 |
2275 |
2276 |
2277 |
2278 |
2279 |
2280 | NotifyIconName
2281 |
2282 | The host or email to check
2283 |
2284 | String
2285 |
2286 | String
2287 |
2288 |
2289 |
2290 |
2291 |
2292 |
2293 |
2294 |
2295 |
2296 |
2297 |
2298 |
2299 |
2300 |
2301 |
2302 |
2303 |
2304 |
2305 |
2306 |
2307 |
2308 |
2309 |
2310 |
2311 |
2312 |
2313 |
2314 |
2315 |
2316 |
2317 |
2318 |
2319 |
2320 |
2321 | For more information, type "Get-Help Show-Balloon -detailed". For technical information, type "Get-Help Show-Balloon -full".
2322 |
2323 |
2324 |
2325 |
2326 | ------------------EXAMPLE 1-----------------------
2327 | Show-Balloon $Message $Title Warning
2328 |
2329 | Shows the $Message and the title $Title using the warning icon
2330 |
2331 |
2332 |
2333 | ------------------EXAMPLE 2-----------------------
2334 | Show-Balloon $Message
2335 |
2336 | Shows a message containing $Message in the taskbar of the computer
2337 |
2338 |
2339 |
2340 |
2341 |
2342 |
--------------------------------------------------------------------------------
/libraries/Sorlov.PowerShell/Sorlov.PowerShell.Core.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | ModuleToProcess = 'Sorlov.PowerShell.Core.dll'
3 | ModuleVersion = '4.0.1.0'
4 | GUID = '656cbed7-901b-4fc2-b72b-19dc760367fe'
5 | Author = ''
6 | CompanyName = ''
7 | Copyright = ''
8 | Description = ''
9 | PowerShellVersion = '2.0'
10 | PowerShellHostName = ''
11 | PowerShellHostVersion = ''
12 | DotNetFrameworkVersion = '3.5'
13 | CLRVersion = ''
14 | ProcessorArchitecture = ''
15 | RequiredModules = @()
16 | RequiredAssemblies = @('Sorlov.PowerShell.Core.dll')
17 | ScriptsToProcess = @()
18 | TypesToProcess = @()
19 | FormatsToProcess = @()
20 | NestedModules = @()
21 | FunctionsToExport = '*'
22 | CmdletsToExport = '*'
23 | VariablesToExport = '*'
24 | AliasesToExport = '*'
25 | ModuleList = @()
26 | FileList = @()
27 | }
--------------------------------------------------------------------------------
/libraries/Sorlov.PowerShell/Sorlov.PowerShell.Format.ps1xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | VersionInformation
6 |
7 | Sorlov.PowerShell.Core.Dto.VersionInformation
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | Component
32 |
33 |
34 | Installed
35 |
36 |
37 | Released
38 |
39 |
40 | ShouldUpgrade
41 |
42 |
43 | CoreComponent
44 |
45 |
46 |
47 |
48 |
49 |
50 | SelfHostedPSInfo
51 |
52 | Sorlov.PowerShell.SelfHosted.Dto.SelfHostedPSInfo
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 10
62 |
63 |
64 |
65 | 10
66 |
67 |
68 |
69 | 12
70 |
71 |
72 |
73 | 20
74 |
75 |
76 |
77 |
78 |
79 |
80 | Path
81 |
82 |
83 | ScriptVersion
84 |
85 |
86 | SignatureStatus
87 |
88 |
89 | ApplicationType
90 |
91 |
92 | GeneratedDate
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/libraries/Sorlov.PowerShell/Sorlov.PowerShell.SelfHosted.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/matthewoestreich/New-PSService/5c737c0c0f949c869c0414e9c781a0575678814e/libraries/Sorlov.PowerShell/Sorlov.PowerShell.SelfHosted.dll
--------------------------------------------------------------------------------
/libraries/Sorlov.PowerShell/Sorlov.PowerShell.SelfHosted.dll-help.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Get-SelfHostedPS
5 |
6 | Gets information about a self hosted PS exe file
7 |
8 |
9 | Copyright © 2013
10 |
11 | Get
12 | SelfHostedPS
13 | 4.2.5.4
14 |
15 |
16 | This cmdlet displays information about a self-hosted file
17 |
18 | Copyright © 2013
19 |
20 |
21 |
22 | Get-SelfHostedPS
23 |
24 | Path
25 | String
26 |
27 |
28 |
29 |
30 |
31 | Path
32 |
33 | The name and path to process
34 |
35 | String
36 |
37 | String
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | For more information, type "Get-Help Get-SelfHostedPS -detailed". For technical information, type "Get-Help Get-SelfHostedPS -full".
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | New-SelfHostedPS
81 |
82 | Exports a PS1 to a EXE file
83 |
84 |
85 | Copyright © 2013
86 |
87 | New
88 | SelfHostedPS
89 | 4.2.5.4
90 |
91 |
92 | This commandlet creates a self-hosted PS1 file as a EXE file
93 |
94 | Copyright © 2013
95 |
96 |
97 |
98 | New-SelfHostedPS
99 |
100 | SourceFile
101 | String
102 |
103 |
104 | DestinationFile
105 | String
106 |
107 |
108 | IconPath
109 | String
110 |
111 |
112 | ServiceName
113 | String
114 |
115 |
116 | ServiceDescription
117 | String
118 |
119 |
120 | ServiceDisplayName
121 | String
122 |
123 |
124 | Service
125 | SwitchParameter
126 |
127 |
128 | FrameworkVersion
129 | String
130 |
131 |
132 | LCID
133 | Int32
134 |
135 |
136 | ThreadMode
137 | STA | MTA
138 |
139 |
140 | Platform
141 | anycpu | x86 | x64
142 |
143 |
144 | BuildDebug
145 | SwitchParameter
146 |
147 |
148 | Version
149 | String
150 |
151 |
152 | EmbedCore
153 | SwitchParameter
154 |
155 |
156 | EmbedModules
157 | PSModuleInfo[]
158 |
159 |
160 | Sign
161 | SwitchParameter
162 |
163 |
164 | Certificate
165 | X509Certificate2
166 |
167 |
168 | TimestampURL
169 | String
170 |
171 |
172 |
173 | New-SelfHostedPS
174 |
175 | SourceFile
176 | String
177 |
178 |
179 | DestinationFile
180 | String
181 |
182 |
183 | IconPath
184 | String
185 |
186 |
187 | HideConsole
188 | SwitchParameter
189 |
190 |
191 | FrameworkVersion
192 | String
193 |
194 |
195 | LCID
196 | Int32
197 |
198 |
199 | ThreadMode
200 | STA | MTA
201 |
202 |
203 | Platform
204 | anycpu | x86 | x64
205 |
206 |
207 | BuildDebug
208 | SwitchParameter
209 |
210 |
211 | Version
212 | String
213 |
214 |
215 | EmbedCore
216 | SwitchParameter
217 |
218 |
219 | EmbedModules
220 | PSModuleInfo[]
221 |
222 |
223 | Sign
224 | SwitchParameter
225 |
226 |
227 | Certificate
228 | X509Certificate2
229 |
230 |
231 | TimestampURL
232 | String
233 |
234 |
235 |
236 |
237 |
238 | SourceFile
239 |
240 | The name and path to process
241 |
242 | String
243 |
244 | String
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 | DestinationFile
253 |
254 | The name and path to output
255 |
256 | String
257 |
258 | String
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 | IconPath
267 |
268 | The icon to embed into the application
269 |
270 | String
271 |
272 | String
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 | HideConsole
281 |
282 | Do not show the console when running
283 |
284 | SwitchParameter
285 |
286 | SwitchParameter
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 | ServiceName
295 |
296 | The name of the service
297 |
298 | String
299 |
300 | String
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 | ServiceDescription
309 |
310 | The description for the service
311 |
312 | String
313 |
314 | String
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 | ServiceDisplayName
323 |
324 | The description for the service
325 |
326 | String
327 |
328 | String
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 | Service
337 |
338 | Create a service instead of a standalone exe
339 |
340 | SwitchParameter
341 |
342 | SwitchParameter
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 | FrameworkVersion
351 |
352 | Force framework version
353 |
354 | String
355 |
356 | String
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 | LCID
365 |
366 | The LCID for the app
367 |
368 | Int32
369 |
370 | Int32
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 | ThreadMode
379 |
380 | Thread mode of application
381 |
382 | ThreadMode
383 |
384 | ThreadMode
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 | Platform
393 |
394 | Target plattform
395 |
396 | Platform
397 |
398 | Platform
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 | BuildDebug
407 |
408 | Build debug files
409 |
410 | SwitchParameter
411 |
412 | SwitchParameter
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 | Version
421 |
422 | Version number for generated assembly
423 |
424 | String
425 |
426 | String
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 | EmbedCore
435 |
436 | Embed core dll in output file
437 |
438 | SwitchParameter
439 |
440 | SwitchParameter
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 | EmbedModules
449 |
450 | Modules to embed
451 |
452 | PSModuleInfo[]
453 |
454 | PSModuleInfo[]
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 | Sign
463 |
464 | Should the file be signed
465 |
466 | SwitchParameter
467 |
468 | SwitchParameter
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 | Certificate
477 |
478 | Manually specify a certificate file
479 |
480 | X509Certificate2
481 |
482 | X509Certificate2
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 | TimestampURL
491 |
492 | The timestamping URL
493 |
494 | String
495 |
496 | String
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 | For more information, type "Get-Help New-SelfHostedPS -detailed". For technical information, type "Get-Help New-SelfHostedPS -full".
532 |
533 |
534 |
535 |
536 |
537 |
--------------------------------------------------------------------------------
/libraries/Sorlov.PowerShell/Sorlov.PowerShell.Types.ps1xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Sorlov.PowerShell.Core.Dto.VersionInformation
5 |
6 |
7 | PsStandardMembers
8 |
9 |
10 | DefaultDisplayProperty
11 | Component
12 |
13 |
14 | DefaultDisplayPropertySet
15 |
16 | Component
17 | Installed
18 | Released
19 | ShouldUpgrade
20 | CoreComponent
21 |
22 |
23 |
24 |
25 |
26 |
27 | Sorlov.PowerShell.SelfHosted.Dto.SelfHostedPSInfo
28 |
29 |
30 | PsStandardMembers
31 |
32 |
33 | DefaultDisplayProperty
34 | Path
35 |
36 |
37 | DefaultDisplayPropertySet
38 |
39 | Path
40 | ScriptVersion
41 | SignatureStatus
42 | ApplicationType
43 | GeneratedDate
44 | Architecture
45 | Modules
46 | SignedBy
47 | TimestampedBy
48 | Files
49 | GeneratorCompany
50 | Copyright
51 | ScriptName
52 | ImageVersion
53 | Company
54 | GeneratorOwner
55 | GeneratorVersion
56 | GeneratedBy
57 |
58 |
59 |
60 |
61 |
62 |
63 | System.Object
64 |
65 |
66 | MSDN
67 |
82 |
83 |
84 |
85 |
86 | System.Array
87 |
88 |
89 | Select
90 |
127 |
128 |
129 | SelectMany
130 |
145 |
146 |
147 | Union
148 |
157 |
158 |
159 | ToList
160 |
168 |
169 |
170 | OrderBy
171 |
208 |
209 |
210 | Where
211 |
264 |
265 |
266 | Any
267 |
318 |
319 |
320 |
--------------------------------------------------------------------------------
/psake.ps1:
--------------------------------------------------------------------------------
1 | # PSake makes variables declared here available in other scriptblocks
2 | # Init some things
3 | Properties {
4 | # Find the build folder based on build system
5 | $ProjectRoot = $env:BHProjectPath
6 | $ModuleName = $env:BHProjectName
7 | $ModuleVersion = (Get-Module -ListAvailable $env:BHPSModuleManifest).Version
8 | $SpecsFolder = (Resolve-Path "$ProjectRoot\Specs")
9 | $TestsFolder = (Resolve-Path "$ProjectRoot\Tests")
10 | $BuildFolder = "$ProjectRoot\$ModuleName\$ModuleVersion"
11 | $Timestamp = Get-date -uformat "%Y%m%d-%H%M%S"
12 | $PSVersion = $PSVersionTable.PSVersion.Major
13 | $HelpOutput = "Results_Help`_$TimeStamp.xml"
14 | $SpecOutput = "Results_Specs_PS$PSVersion`_$TimeStamp.xml"
15 | $ApiKey = $env:APIKEY
16 | }
17 |
18 | Task Default -Depends Test
19 |
20 | Task Build {
21 | Write-Host "Building Module Structure" -ForegroundColor Blue
22 | $Functions = Get-ChildItem -Path $ProjectRoot\Source\Functions -Recurse -Exclude *.Tests.* -File `
23 | | ForEach-Object -Process {Get-Content -Path $_.FullName; "`r`n"}
24 | If (-not (Test-Path $BuildFolder)) {
25 | Write-Host "Creating Output Folder" -ForegroundColor Blue
26 | $Null = New-Item -Path $BuildFolder -Type Directory -Force
27 | } Else {
28 | Write-Host "Clearing Existing Output Folder" -ForegroundColor Blue
29 | $Null = Remove-Item -Path $BuildFolder -Recurse -Force
30 | }
31 | Write-Host "Placing Dependencies" -ForegroundColor Blue
32 | $Null = Copy-Item -Path "$ProjectRoot\Source\libraries" -Container -Recurse -Destination $BuildFolder\Libraries -Force
33 | Write-Host "Copying Module Manifest" -ForegroundColor Blue
34 | $Null = Copy-Item -Path "$ProjectRoot\Source\$ModuleName.psd1" -Destination $BuildFolder -Force
35 | Write-Host "Creating and compiling Module file" -ForegroundColor Blue
36 | $Null = New-Item -Path "$BuildFolder\$ModuleName.psm1" -Type File -Force
37 | $Null = Add-Content -Path "$BuildFolder\$ModuleName.psm1" -Value $Functions,"`r`n"
38 | $Null = Get-Content -Path "$ProjectRoot\Source\$ModuleName.psm1" `
39 | | Select-Object -Last 1 `
40 | | Add-Content -Path $BuildFolder\$ModuleName.psm1
41 |
42 | Write-Host "Module built, verifying module output" -ForegroundColor Blue
43 | Get-Module -ListAvailable "$BuildFolder\$ModuleName.psd1" `
44 | | ForEach-Object -Process {
45 | $ExportedFunctions = $_ `
46 | | Select-Object -Property @{ Name = "ExportedFunctions" ; Expression = { [string[]]$_.ExportedFunctions.Keys } } `
47 | | Select-Object -ExpandProperty ExportedFunctions
48 | $ExportedAliases = $_ `
49 | | Select-Object -Property @{ Name = "ExportedAliases" ; Expression = { [string[]]$_.ExportedAliases.Keys } } `
50 | | Select-Object -ExpandProperty ExportedAliases
51 | $ExportedVariables = $_ `
52 | | Select-Object -Property @{ Name = "ExportedVariables" ; Expression = { [string[]]$_.ExportedVariables.Keys } } `
53 | | Select-Object -ExpandProperty ExportedVariables
54 | Write-Output "Name : $($_.Name)"
55 | Write-Output "Description : $($_.Description)"
56 | Write-Output "Guid : $($_.Guid)"
57 | Write-Output "Version : $($_.Version)"
58 | Write-Output "ModuleType : $($_.ModuleType)"
59 | Write-Output "ExportedFunctions : $ExportedFunctions"
60 | Write-Output "ExportedAliases : $ExportedAliases"
61 | Write-Output "ExportedVariables : $ExportedVariables"
62 | }
63 | }
64 |
65 | Task Test -Depends Build {
66 | Write-Host "Testing Module Help" -ForegroundColor Blue
67 | $HelpResults = Invoke-Pester $TestsFolder -OutputFormat NUnitXml -OutputFile $HelpOutput -PassThru
68 | If ($HelpResults.FailedCount -gt 0) {
69 | Exit $HelpResults.FailedCount
70 | }
71 | # This will be uncommented once we're ready to actually start using gherkin.
72 | #Write-Host "Testing Module Specifications" -ForegroundColor Blue
73 | #$SpecResults = Invoke-Gherkin $SpecsFolder -OutputFormat NUnitXml -OutputFile $SpecOutput
74 | }
75 |
76 | Task Deploy -Depends Test {
77 | Write-Host "Deploying the module to the Gallery" -ForegroundColor Blue
78 | $GalleryModule = Find-Module -Name $ModuleName -ErrorAction SilentlyContinue
79 | Try {
80 | If ([string]::IsNullOrEmpty($GalleryModule) -or ($GalleryModule.Version -lt $ModuleVersion)) {
81 | Publish-Module -Path "$BuildFolder" -NuGetApiKey $ApiKey -ErrorAction Stop -Verbose
82 | } Else {
83 | Throw "Version of the module being published is not higher than the version on the gallery!"
84 | }
85 | } Catch {
86 | Format-List -InputObject $Error[0] -Force -Property *
87 | exit 0
88 | }
89 | }
90 |
--------------------------------------------------------------------------------