Hi
I am new to Power shell. As am
trying to get output result in a table format. But still am getting
output in a single column.
I am getting output as below:
Alerter
Stopped
ALG
Running
AppMgmt
Stopped
aspnet_state
Stopped
But I need as below format:
Name State
——– —- —–
Alerter Stopped
ALG Running
AppMgmt Stopped
aspnet_state Stopped
Below is the command am going try to get "Win32_Service" Names
and its State:
———————————————————————————-
cls
$column1 = @{expression="Name"; width=20;label="Name";
alignment="left"}
$column2 = @{expression="State"; width=10;label="State";
alignment="right"}
$c = Get-WmiObject Win32_Service | ForEach-Object {$_.Name,$_.State}
$c | Format-Table $column1, $column2 > "G:studypower
shellprocprop1.txt"
———————————————————————————————————-
And also I tried below Command:
————————————————————————————————————
cls
$c = Get-WmiObject Win32_Service | ForEach-Object {$_.Name,$_.State}
$c | Format-Table Name,State > "G:studypower
shellwmiservice.txt"