PowerCli 6 Script Questions

I am not very good in PowerShell yet and create the following script to check the values listed below. Ideally I would like all results displayed in one out-gridview with the name of the host listed to the right or left of each value and be able to use a variable in my host name so I can scan multiple host but having problems getting a variable to work. I think I am 50% there and was hoping for some additional guidance.

get-advancedsetting -entity server1 -name datamover.hardwareAcceleratedMove | out-gridview
get-advancedsetting -entity server1 -name DataMover.HardwareAcceleratedInit | out-gridview
get-advancedsetting -entity server1 -name VMFS3.HardwareAcceleratedLocking | out-gridview
get-advancedsetting -entity server1 -name VMFS3.EnableBlockDelete | out-gridview
get-advancedsetting -entity server1 -name DataMover.MaxHWTransferSize | out-gridview
get-vmhost -name server1 | esxcli storage nmp satp rule list | out-gridview

Open in new window

LVL 21
compdigit44Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wasim ShaikhCommented:
Get-advancedSetting give one type of objects and esxcli another type.
May be you will have to run both of them seperately.
Assuming you have multiple Hosts and want to retrieve values for all of them try the scipt below.
NOTE: Each code block is doing the same thing, its just the different way to get the results.
Output without Formatting
$filter=@("DataMover.HardwareAcceleratedMove","DataMover.HardwareAcceleratedInit","VMFS3.HardwareAcceleratedLocking","VMFS3.EnableBlockDelete","DataMover.MaxHWTransferSize")
Get-VMHost | Get-AdvancedSetting | where{$filter -contains $_.Name} | Select Entity, Name, Value | Sort-Object -Property Entity

Open in new window

Output formatted Table
$filter=@("DataMover.HardwareAcceleratedMove","DataMover.HardwareAcceleratedInit","VMFS3.HardwareAcceleratedLocking","VMFS3.EnableBlockDelete","DataMover.MaxHWTransferSize")
Get-VMHost | Get-AdvancedSetting | where{$filter -contains $_.Name} | Select Entity, Name, Value | Sort-Object -Property Entity | FT -AutoSize

Open in new window

Output Grid
$filter=@("DataMover.HardwareAcceleratedMove","DataMover.HardwareAcceleratedInit","VMFS3.HardwareAcceleratedLocking","VMFS3.EnableBlockDelete","DataMover.MaxHWTransferSize")
Get-VMHost | Get-AdvancedSetting | where{$filter -contains $_.Name} | Select Entity, Name, Value | Sort-Object -Property Entity | Out-GridView

Open in new window

Output to a .CSV file (remember to change the -path)
$filter=@("DataMover.HardwareAcceleratedMove","DataMover.HardwareAcceleratedInit","VMFS3.HardwareAcceleratedLocking","VMFS3.EnableBlockDelete","DataMover.MaxHWTransferSize")
Get-VMHost | Get-AdvancedSetting | where{$filter -contains $_.Name} | Select Entity, Name, Value | Sort-Object -Property Entity | Export-Csv -Path d:\Info.csv -NoTypeInformation

Open in new window

compdigit44Author Commented:
This is very interesting ....

I understand that $filter is a variable but what is the purpose of the @ syn.. Also after the Get-VMhost I could add -name to add a list of specific host correct.
Wasim ShaikhCommented:
$filter is array.
Get-VMHost find all the ESXi host in your environment.
If you want only 1 host then can add just after the cmdlet.
$filter=@("DataMover.HardwareAcceleratedMove","DataMover.HardwareAcceleratedInit","VMFS3.HardwareAcceleratedLocking","VMFS3.EnableBlockDelete","DataMover.MaxHWTransferSize")
Get-VMHost MyHostName | Get-AdvancedSetting | where{$filter -contains $_.Name} | Select Entity, Name, Value | Sort-Object -Property Entity

Open in new window

For Multiple Hosts
$filter=@("DataMover.HardwareAcceleratedMove","DataMover.HardwareAcceleratedInit","VMFS3.HardwareAcceleratedLocking","VMFS3.EnableBlockDelete","DataMover.MaxHWTransferSize")
Get-VMHost MyHostName1, MyHostName2 | Get-AdvancedSetting | where{$filter -contains $_.Name} | Select Entity, Name, Value | Sort-Object -Property Entity

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

compdigit44Author Commented:
Thank you very much.. I am going to read up more on PowerShell arrays and will give the scripts a try tomorrow..
compdigit44Author Commented:
Wow great advance as always!!!
compdigit44Author Commented:
You script works really well... IS there any way to else include the SATP list output with in the Grid... I am just checking to see it a rule is present for a storage device starting with "PURE"
Wasim ShaikhCommented:
SATP query cannot be added in same script block, but if the script is broken down in functions then might be possible to get output in HTML.
this kind of scripts take time to develop.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VMware

From novice to tech pro — start learning today.