I am very new to Powershell, and coding as a whole, and have really only begun to realize what it can do for me. I am new to the company I'm working for as well, and one thing they are lacking is Operations Manager, or any real reporting tool. I've begun to try to use PS for this. I've been successful at some scripts but one thing I wanted to do was to create a list of disks, which aggr they are assigned to, as well as the raid state. I've entered this command get-nadisk | ft disktype,aggregate,raidstate -autoto get this output (just a sample):
DiskType Aggregate RaidState -------- --------- --------- FCAL spare ATA partner ATA partner ATA partner ATA sata0 present
What I want to be able to do is write a script that will omit the "partner" disks and only show the present and spare disks. I was thinking that a "where" statement might work, but then I'm thinking that will only pull one of the 3 raid states. Then I was thinking I might want to further sort FC and SATA disks as well as present or partner and my head started to spin. How would I go about filtering down my results? If I do use a "where" statement, what property would I use to define the RaidState column?
If you want to re-use any of the intermediate states, you can also use variables. Storing intermediate values in variables can also be helpful in troubleshooting errors in your scripts. Also, if you want to include comments, they are preceded with the # character.