Server,Service,Startup Type,Task DCVPIM108,SQL Server Analysis Services (MSSQLSERVER),automatic,running server2,“SQL Server Analysis Services (MSSQLSERVER), SQL Server Analysis Services (MSSQLSERVER) CEIP”,Manual,stopped
my `-PipelineVariable svc`is not working as intended. if a service was “stopped” and “Manual” before being changed to “running” and “automatic”, it doesnt get the old values “stopped” and “Manual” for `OldStatus` and `OldStartType`
<p class=“lang-none prettyprint prettyprinted”>MachineName : DCVPIM108 Name : MSSQLServerOLAPService Status : Running StartType : Automatic OldStatus : Running OldStartType : Automatic</p>
I don’t know what’s in the csv file, but maybe you should put the select-object inside the foreach-object loop, which is probably running multiple times.
[quote quote=121320]I don’t know what’s in the csv file, but maybe you should put the select-object inside the foreach-object loop, which is probably running multiple times.
[/quote]
i added the csv to my post, if i put select object inside then wouldnt it overwrite?
[quote quote=121342][/quote]
but the whole point of e={$svc.Status} is it should be able to solve the expression from the -PipelineVariable…so then i would have to remove it from my script as its useless huh?
[/quote]
lol great. and the person who suggested this to me claimed he was an expert on microsoft support. i ended up wasting my time with this N and E expression…
Why do you have two service specified in your csv on the same line for server2?
These should, IMHO, be separate line items relative to the types of getter / setter effort you are trying to do.
The results are as shown below, and no issues observed even with the ‘manual’ or ‘stopped’ status.
[/quote]
Let's talk about SQL01 machine. Let's say the service was stopped, and set to manual start type. Keep your csv file as is please and run the script. Paste results here (the old status should be different from new status, but that's not what I saw in those results, so pipelinevariable isnt working
[quote quote=121431][/quote]
the output is not right.
in my csv, if the service status is stopped, but it is running on the server, what SHOULD be outputted is:
status: stopped
oldStatus: running
because the old status was running and because in csv file i defined it to stop running, the statuses would be different. that is my issue with -PipelineVariable svc. it should be getting the current status of the service BEFORE it gets set by the ensuing command.
this applied to the startuptype btw.
and sure, if i had the csv file say running and the service is already running, then cool, i would expect both to say the same thing. but the issue here is its NOT getting the current status before setting it.
[quote quote=121500]By the way, ‘start’ isn’t valid for the ‘set-service -status’ parameter in the csv. It should be ‘running’.
[/quote]
Edited my post.
As for your output,
the output is not right.
in my csv, if the service status is stopped, but it is running on the server, what SHOULD be outputted is:
status: stopped
oldStatus: running
because the old status was running and because in csv file i defined it to stop running, the statuses would be different. that is my issue with -PipelineVariable svc. it should be getting the current status of the service BEFORE it gets set by the ensuing command.
this applied to the startuptype btw.
and sure, if i had the csv file say running and the service is already running, then cool, i would expect both to say the same thing. but the issue here is its NOT getting the current status before setting it.
[quote quote=121525][/quote]
yessss finally! THAT is what i have been looking for! OMG that took so many days and so many resources to ask. not even stackoverflow folks knew how lol
to summarize the problem for anyone in teh future having this issue:
PipelineVariable is DYNAMIC. what this means is if the variable’s properties is modified (i.e. set-service -status) then the status property will change and will ALSO change whatever the pipeline variable status was. this is unfortunate and it should not behave like this.
THANK YOU JS! after 3 days this issue can finally be put to rest!
It’s not that pipevariable is dynamic, but the StartType and Status properties in the ServiceController object are dynamic. I’ve never dealt with it before.