Asking for a bit of help with my script. I would like to get a list saved to a thumb drive with the computer name and the WAN address. I know I can add a custom label with the computer name but would get the default name. I already set the computer to change the name on reboot but I do not want to reboot as there are other things that need to happen before rebooting. The computers are new and are not added to the domain. I have a thumb drive that will auto-load and assist in changing the name without asking to reboot. So other software can install.
This is what I have so far:
getmac /v /FO CSV | ConvertFrom-Csv | Select-Object @{n='ComputerName';e={$env:COMPUTERNAME}},'Physical Address','Connection Name' | Where-Object { $_.'Connection Name' -Match 'Wi-Fi' }
And this is the output:
ComputerName Physical Address Connection Name
------------------ ------------------ --------------------
Desktop-9K293 XX-XX-XX-XX-XX Wi-Fi
I want the ComputerName to be the new name before rebooting. This way I can add an Export-CSV ~Location\MAC_Report.CSV -NoTypeInformation -append
at the end of that code. Is there a way? Or do I need to restart the computer and generate that CSV using the same code?
I would love it to look:
ComputerName Physical Address Connection Name
------------------ ------------------ --------------------
NEW_____Name XX-XX-XX-XX-XX Wi-Fi
There are a lot of things I can make my thumb drive do. This way I have fewer restarts before adding the rest of the software(s) that also requires a restart. This way I cut my restart to one, on both all the software and computer rename.
I ended up just saving a TXT to the desktop of the computer, this way I can add the new computer name manually. This way I can then grab all the text files and consolidate them into one CSV or txt file. A bit of work but at least I can set the restart for later while I am able to install the rest of the software.
getmac /v /FO CSV | ConvertFrom-Csv | Select-Object 'Physical Address','Connection Name' | Where-Object { $_.'Connection Name' -Match 'Wi-Fi' } | Export-CSV -Path "$env:USERPROFILE\Desktop\WLAN_MAC.TXT" -NoTypeInformation
If there was a better way I would have done it.