netdom remove %computername% problem RRS feed

  • Question

  • I am having a problem with this script and not recognizing the %computername%

    foreach ($vm in $vms)

    invoke-vmscript -vm $vm -guestuser administrator -guestpassword xxxxx -scripttype bat -scripttext 

    'net dom remove %computername% /userd:administrator /passwordd:yyyyyy /reboot /force' -verbose

    any idea why it cannot recognize the %computername%

    • Moved by Bill_Stewart Friday, March 15, 2019 3:03 PM Help vampire
    Wednesday, December 12, 2018 5:43 AM

All replies

  • % variables do not work in PowerShell.  The PS variable is $env:COMPUTERNAME.

    Get-ChildItem env:

    In PowerShell we would use Add-Computer to join or unjoin a domain/

    help Add-Computer -Online


    Wednesday, December 12, 2018 6:07 AM