0

I'm trying to simply get some data into a variable (this s just an example of my issue, much bigger script in the works),

$var=get-physicaldisk

This works if I type it out in powershell, but if I try to script is with ps1 the variables never get filled. one method Ive used for other variables because of this was the set-variable, but this cant seem to be used in conjunction with a get command.

Kilaj1
  • 1
  • 1

1 Answers1

0

If you are trying to get the $var to show up after the script is complete, use this formatting. BEWARE!-- the variables will continue to exist in that powershell session until it is closed

$global:foobar=get-process

You can also use $script:foobar=get-process to have the variable persist throughout the script (within functions and loops)