Powershell Tool in Inventory - Rename domain joined computer
Hi wondering if its possible to have a pop-up screen that takes a new hostname into a variable that then gets passed to a powershell command.
eg
Rename-Computer -NewName (Variable) -force -restart Variable = popup entry??
0
Comments
This purges the local certs for 802.1x , Gets the Serial number from bios Creates a variable with a preset front part and serial number Renames the computer and forces a restart
we use the above as an inventory Tool with remote run. You could modify to change the host name based off the old by calling host name or doing
so
You could probably use the built in PDQ variables to modify this to run local but we had the best success running it as remote.
Thanks sean, that looks quite nice but still missed the basic pop-up window that allow the "whateverfrontpartwewant" to be keyed then inserted into new name using powershell. the front part for us is usually a 3 letter abbreviation that changes.
I did some digging. best way I could find to create the popup and return it as a value is below. Running this local now instead of remote.
my reference for this https://stackoverflow.com/questions/30534273/simple-inputbox-function https://stackoverflow.com/questions/16208013/make-input-box-with-predefined-value
Edit revised and cleaned up some Worked on my end up to getting access denied on rename, I think I remember this being some quirk that I didn't want to research. This is why I ran our other script local. Perhaps I'm missing something but your box popup is in this one. It references the computer name from PDQs variable, to test just the popup in PS without PDQ first run. I'm sure you can edit it to get what you need out of it.
champion, never played with powershell windows so didnt occur to me. this worked perfectly. đŸ˜„
Cant make variables work??
PC-1234 : Ther term 'PC-1234' is not recognised as the name of a cmdlet, function, script file or operable program. How does one pass the PDQ variable into powershell as it doesnt work.
also when i use the command:
no windows pops up for credentials to be entered. I'm trying to do this as need to run the Rename-Computer with credentials and the Tool doesnt pass them to powershell.
$oldComputerName = '$(COMPUTER:TARGET)' pass it with ' '
For the pop up box you may need to select close shell on completion (or leave it open) in the tool editor under Shell
If you use the tool window I think it suppresses input like that.
champion
The issue i'm having with this is that in order to get the popup to work the command needs to be run local. but then because its local the pop-up works and the script gives me a Sucess Code: 0.. But nothing happens on the remote machine. In this case i can run it as the PDQ service account or a Domain\Admin with the same result.
If I just run the command without prompts as "Remote" all works fine, its the input above that breaks it.
do the credentials field lower in the tool apply to the powershell commands being executed, or is that only for scanning??
Recently had to rename 500 computers on my campus. I used this script in powershell to make it work. Use PDQ to make sure the powershell that is installed on your computers is Powershell 3.0 or above and then run it directly from powershell no need for pdq at this point. Place a csv file with the list of old computer names and new computers and call for it with the following script. Script will also have you authenticate with your admin credentials one time with a popup and then it will automatically repeat it for all of your hosts. If you get a wmi error you will need to change your remote administration settings on the computer who's name you are trying to change to be allowed in windows firewall. As far as the csv file goes do one column with heading OldName and one column with Heading NewName make sure to designate the path for where you want to pull your csv from so for example if you have put your file in the root of C:\ change the directory in your script to C:\ best of luck to you once I figured this out it saved me so much time.
cd C:
$Credential = Get-Credential $a = Import-Csv yourcsvfile.csv -Header OldName, NewName Foreach ( $Server in $a ) {Rename-Computer -ComputerName $Server.OldName -NewName $Server.NewName -DomainCredential $Credential -Force -Restart}
Is there possible to rename for windows 7 client domain-joined without Powershell?Â