This is an easy one and just me being stupid, i am running the below but for some reason now i have used mandatory=$true it now longer adds the message section.
This is the parameter i am using,
[CmdletBinding()]
param(
[Parameter(Mandatory=$True)]
[String] $UpdateDay = (Read-Host -Prompt ‘Enter Value for the Day Windows updates will install. Sunday = 1, Monday = 2,
Tuesday =3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7’),
[string] $UpdateTime = (Read-Host -Prompt ‘Enter update time. Values use the numner to represent hour on a 24 Hour clock,
i.e (03:00 =3) (18:00 = 18)’)
)
And below is the output i get rather than including the output to user,
cmdlet at command pipeline position 1
Supply values for the following parameters:
UpdateDay:
function test {
[CmdletBinding()]
param(
[Parameter( Mandatory=$True,
HelpMessage="Enter Value for the day Windows updates will install. Sunday = 1, Monday = 2, Tuesday =3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7"
)][String] $UpdateDay,
[Parameter( Mandatory=$True,
HelpMessage="Enter update time. Values use the number to represent hour on a 24 Hour clock, i.e (03:00 =3) (18:00 = 18)"
)][string] $UpdateTime
)
}
Thank you for the help, i have changed the script block to include a help message and convert the input to numeric later on. On a separate note how do you add the power-shell box Jeremy used in his post, this will help make my next post more clear?
The Script is now working :). However, the script i was writing was to automate the local group policy settings i generally use on server builds, such as setting WSUS server location. The script was using the Set-ItemProperty commands to edit the regisrty, now that the script runs i have noticed that gpupdate or logon/logoff overwrites the values that i have set, is there a way to stop this or a better way of doing this?
I cannot add these to a domain as they are tailored for each clients needs and most do not want a domain controller. I have googled this but all solutions are generally installing third party software etc, which would take just as much time to do each time as just editing the local GP.
Thanks for the advice, they are client servers that are bespoke for hosted applications etc. Naturally most clients are not willing to add the cost of a domain controller to manage the 1-2 servers they have with us.
Ah, makes total sense now. Yeah, a startup script should do the trick. Or you could look into PowerShell DSC. Could give you more granularity and easier to manage in the long run.