The Issue I am facing is when I have only one Hard drive and one partition , the script execute successfully with valid return.
However When a Server is having more than one physical disk or more than one partition it is returning no value for $dskobj properties. Well I understand why it is doing it , because it doesn't know how to present it. However I can't think of any way to present this data.
Because you're returning an array, you'll need to approach it a little bit differently. I haven't put the credential info back in, just adapt this to your needs and see if it works :)
I have added the credential part and it is working as I wanted. Thanks for your help!!
Now few silly questions to annoy you.
1. What is %{} ? - You piped output of win32_diskdrive into this container is it same as an array @()
Few operation inside the %{} is bit difficult for a newbie like me understand. I understand the Associators of query , however why aren't you doing the same operation for $_.Model as you are doing for $_.deviceid..
Thing is I am writing more functions like this and I can only use wmi queries for data from the servers as none of they will have powershell. So it would be great to know how this is working so that I keep building my shared function scripts
% is a bad habit :) I forgot to replace that with the actual cmdlet when copying it over.
It is a shortcut for the ForEach-Object cmdlet. For example, these will do the same thing.
? is a shortcut for Where-Object, so if you see people piping to ? that's what that is all about.
The reason you don't need to do this to find the model and deviceID, is that there is only 1 reference to each physical device so for each drive in the target host you can assume the model and status will be the same for each partition on that drive.
Brilliant answers all my Questions!!!!
One thing now I have to figure out , How to add a new property (like : win32_timezone.caption ) to the existing psobject ($objdiskinfo)
0
Featured Post
WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network. Check out this quarters report on the threats that shook the industry in Q4 2017.
In this post, I will showcase the steps for how to create groups in Office 365.
Office 365 groups allow for ease of flexibility and collaboration between staff members.
In migration, Powershell can be a very crucial tool to achieve success and finalize projects within deadline or even fix issues.
X500 or Legacy Exchange DN Attribute can cause lots of issue during the migration