B
B
BoryanNikitin2020-11-11 14:49:53
PowerShell
BoryanNikitin, 2020-11-11 14:49:53

Why Get-AppxPackage | Select-Object Name is empty string in loop?

Hello! There is the following cycle

for ($i = 0; $i -ile 2; $i++){
  Start-Sleep(4)
  Get-AppxPackage | Select-Object Name
}

Why is the result of execution at the zero iteration Get-AppxPackage | Select-Object Namean empty string, although the rest of the iterations work properly? Without Select-Object or without a loop, everything works fine, but I need to output exactly for a specific field in the loop.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
azarij, 2020-11-11
@BoryanNikitin

If I understood the question correctly, then this is how it seems to work as you need.

for ($i = 0; $i -ile 2; $i++){
  Start-Sleep(4)
  #$i
  (Get-AppxPackage).Name
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question