ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Understand CMD CLI to Powershell Variable

    Scheduled Pinned Locked Moved IT Discussion
    cmdcmdletpspowershellchocolateybatchscriptscripting
    2 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gjacobseG
      gjacobse
      last edited by

      I'm not sure that is the correct way of phrasing what I wish to do. It boils down to the group of scrips I am building and have built thus far - and pushing a PS command via batch command.

      I've been using Chocolatey.org to install software, so it starts out with the Powershell script to do so.

      From there, I install my applications using simple Windows CMD batch file which then also installs Webroot via the MSI.

      The last thing I'm doing is renaming the computer using PowerShell with this command:

      powershell Rename-Computer -NewName "NiceComputerName" -DomainCredential domain\admin -Restart
      

      Right now I am having to edit the batch file for each computername - something I'm trying to get to where I can avoid.

      So I need to pass the variable or parameter from CMD to PS on prompt, so I can just right click the batch - run as Admin.

      As I'm not a strong much less basic PS user, how would that be done... A quick search shows it seems to be possible,.. just not fully understanding the context.

      dbeatoD 1 Reply Last reply Reply Quote 0
      • dbeatoD
        dbeato @gjacobse
        last edited by dbeato

        @gjacobse So basically you want to iterate through a list of computers the same script correct? So do you have a list of computers? What are other steps on your script? because what we can do is the following

        *$computers = import-csv -Path "c:\script\computers.csv" foreach ($oldname in $computers){ Rename-Computer -NewName $newname -DomainCredential domain\admin -Restart}

        This assumes you have a CSV file with a oldname and new name columns with computer names.

        1 Reply Last reply Reply Quote 2
        • 1 / 1
        • First post
          Last post