Creating a Windows Service that uses a parameter
Posted: Thu Aug 27, 2020 6:19 pm
Product, version and build: PrimalScript 2020, Version 7.7.142
Operating system: Windows 10 Enterprise
PowerShell version: v5
32 or 64 bit OS: 64 Bit
Hi, I am all googled out and am seeking help/advice.
I have a PS script that will monitor a folder for new files, this works fine.
I wish to turn it into a Windows Service and am using the PrimalScript 2020 PowerShell Service template. I want to be able to use this anywhere so have opted for the script to bring in data on start from an xml file, this is where I am lost. Below is some of my script that shows the start parameter but the service when starting does not recognise it as I receive a app log entry "Line 2: Cannot process command because of one or more missing mandatory parameters: Start." The parameter is the path to the xml file. I suspect I am putting this in the wrong place but cannot find how it should look.
.......................
function Start-MyService
{
# [CmdletBinding()]
param(
[Parameter(ParameterSetName='Start', Mandatory=$true)]
[string]$Start
)
................
Can anybody shine some light on this for me?
Thanks in advance
Wayne
Operating system: Windows 10 Enterprise
PowerShell version: v5
32 or 64 bit OS: 64 Bit
Hi, I am all googled out and am seeking help/advice.
I have a PS script that will monitor a folder for new files, this works fine.
I wish to turn it into a Windows Service and am using the PrimalScript 2020 PowerShell Service template. I want to be able to use this anywhere so have opted for the script to bring in data on start from an xml file, this is where I am lost. Below is some of my script that shows the start parameter but the service when starting does not recognise it as I receive a app log entry "Line 2: Cannot process command because of one or more missing mandatory parameters: Start." The parameter is the path to the xml file. I suspect I am putting this in the wrong place but cannot find how it should look.
.......................
function Start-MyService
{
# [CmdletBinding()]
param(
[Parameter(ParameterSetName='Start', Mandatory=$true)]
[string]$Start
)
................
Can anybody shine some light on this for me?
Thanks in advance
Wayne