none
Powerhsell: variable in a variable? RRS feed

  • Question

  • Hi,

    I have a script that deploys an application to a usergroup (SCCM). It works fine but I have a lot of variables which I would like to reduce.

    F.e.:
    *The name of the application = $appname consists of the vendor, applicationname and version
    *The usergroup consists of environment (DEV/UAT/PRD) then vendor applicationname
    etc

    So is this the correct way to achieve this?
    $appname = "$vendor - $applicationname - $version"
    $vendor = "Microsoft"
    $applicationname = "WordViewer"
    $version = "1.0"

    Please advise.
    J.


    Jan Hoedt

    Friday, March 13, 2015 9:42 AM

Answers

  • Well, it looks like, don't see any problem, I have just tested that and this is the result:

    PS C:\WINDOWS\system32> $vendor = "Microsoft"
    PS C:\WINDOWS\system32> $applicationname = "WordViewer"
    PS C:\WINDOWS\system32> $version = "1.0"
    PS C:\WINDOWS\system32> $appname = "$vendor - $applicationname - $version"
    PS C:\WINDOWS\system32> $appname
    Microsoft - WordViewer - 1.0

    Anything I'm missing?

    • Marked as answer by janhoedt Friday, March 13, 2015 9:54 AM
    Friday, March 13, 2015 9:50 AM

All replies

  • Well, it looks like, don't see any problem, I have just tested that and this is the result:

    PS C:\WINDOWS\system32> $vendor = "Microsoft"
    PS C:\WINDOWS\system32> $applicationname = "WordViewer"
    PS C:\WINDOWS\system32> $version = "1.0"
    PS C:\WINDOWS\system32> $appname = "$vendor - $applicationname - $version"
    PS C:\WINDOWS\system32> $appname
    Microsoft - WordViewer - 1.0

    Anything I'm missing?

    • Marked as answer by janhoedt Friday, March 13, 2015 9:54 AM
    Friday, March 13, 2015 9:50 AM
  • Ok, it looked to easy/good to be true :-).
    Thanks.

    Jan Hoedt

    Friday, March 13, 2015 9:54 AM