Passing variables between commands with one single line command

Welcome Forums General PowerShell Q&A Passing variables between commands with one single line command

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 6 months ago.

  • Author
    Posts
  • #26862

    Participant
    Points: 0
    Rank: Member

    Hi I am Jiten, Here's my question:
    I want to run two commands back to back. Command2 uses object of Command1.
    Eg.
    Command1: $ptt = Get-WmiObject -namespace "root/cimv2/security/microsofttpm" win32_tpm

    Command2: $ptt.IsEnabled()

    I am trying to run these command through Python Subprocess module. But problem is that i can run only i command at a time. I tried using Export-Clixml but in that also i have to run Import command first.

    Kindly help me on this . I will be really grateful.

    Regards,
    JB

  • #26866

    Participant
    Points: 428
    Helping Hand
    Rank: Contributor

    I don't know anything about Python, but this can be run as a single command:

     
    (Get-WmiObject -namespace "root/cimv2/security/microsofttpm" -Class win32_tpm).IsEnabled()
    
  • #26867

    Participant
    Points: 0
    Rank: Member

    Thanks Man !! Its worked. Thanks alot.

    Regards,
    JB

The topic ‘Passing variables between commands with one single line command’ is closed to new replies.