i have an odd issue for when i run this command:
Set-DhcpServerv4Reservation -computer name -ip 1.1.1.1 -clientid macaddress
it removes a few other variables, such as "root path". when I run get-dhcpreservation on an IP that has all of its variables set, "root path" is not something it returns, and it is not something that I can set with powershell -- plus, i'd rather it not be removed.
are there any other methods to update a dhcp reservations mac address?
after fiddling around with Set-DhcpServerv4Reservation there is really no way to set the mac address with that command without deleting option values that are set, such as iscsi targets. there is also seemingl
the fix was using Get-DhcpServerv4OptionValue to store what would be deleted as a variable, use set-dhcpserver4reservation to set the MAC address, then use set-dhcpserverv4optionvalue to add back what was deleted.
not the most ideal solution but i was successfully able to update the mac address while preserving everything that the command was deleting.
Related
I have a task to set up a Windows 2008 server in AWS, fully scripted.
I need to add a user but so far have tried dsadd with no apparent results. I tried various permutations of the command and finally copied and pasted the example:
dsadd user “cn=John Smith,ou=SouthEmployees,dc=northwindtraders,dc=com” -disabled no –pwd C^h3Bdo9# -mustchpwd yes
But nothing extra shows up in the server manager list of local users, and the command just returns with no indication of error or success.
Any idea on what I'm doing wrong, or another way to do this?
This had to be done with PowerShell:
# Add required ID
$server=[ADSI]"WinNT://$env:computername"
$user=$server.Create('User','my_username')
$user.SetPassword('longpassword')
$user.SetInfo()
I am using Windows Server 2012-R2 (amazon ec2) machine.
and I want to change and verify hostname in it. I checked on net and found hostname command. But when I run hostname or hostname -i command I get following error..
sethostname: Use the Network Control Panel Applet to set hostname.
hostname -s is not supported.
I further googled this problem and apparently this command is not usable on windows 2012-r2 servers. Is there any alternative or workaround command that can do the job for me??
On windows the computer name is also often referred to as hostname. However this creates some confusion. Some people use the term hostname to refer to the leftmost part of domain name which can only be set on a DNS server. However another meaning of a hostname is just an arbitrary label assigned to a machine on a computer network, and this can be directly changed on the specific machine.
There are several ways to change the computer name from the command line on windows 2012:
Method 1. Open cmd and type:
SCONFIG and you will get selection menu where #2 says Computer Name:
Method 2. From cmd type:
netdom renamecomputer %computername% /newname:<NewName> /reboot:0
Method 3. From the PowerShell console:
netdom renamecomputer $env:computername /newname:<NewName> /reboot:0
To verify the name form cmd type:
nbtstat -A xxx.xxx.xxx.xxx (where x is the ip address)
Another way to verify the name form cmd just type "hostname" without any parameters:
hostname
Is it possible to get IP from MAC Address of printer.
I have got MAC address and want to know what IP is assigned to it via DHCP server.
I tried the below query and it does give me all the IP address in scope but I need to be able to search for the one I am looking for.
netsh dhcp server \\DHCP server scope 10.65.22.0 show clients 1
I tried using Where {$_.uniqueID -like "002128903a09"} but it does not seems to like it.
Thanks
So netsh is an external application, and will return a bunch of text, but not objects, so you can't check a property (like $_.uniqueID) using a Where statement. You have two options here, you can search for the line of text that has your MAC and consume the whole line, or you can parse the text and convert it to objects. I am not familiar with the results that get spit out when you run that command, so if you want to give a sample of that (update your question to include it, don't put it in a comment), I can probably help you parse the text into objects, or just search it for a MAC address.
Or, one option would be to pipe the command into the Select-String cmdlet, and have that search for your MAC address.
$MACAddr = ("002128903a09" -split "(..)"|?{$_}) -join "-"
netsh dhcp server \\DHCP server scope 10.65.22.0 show clients 1 | Select-String -SimpleMatch $MACAddr
I believe that will at least find the line that has your MAC, and you can get the IP from there.
Edit: Updated with MAC Address formatting corrected, thanks to #JanChrbolka for helping me with the correct format!
I have a script that I run to lockdown a windows 7 computer to run a VM Client when booted.
when it runs it creates the local user account that is going to be used for logging in
Checks for the DefaultPassword reg key and if is not there creates the key
It sets the registry values for
AutoAdminLogon value to 1
DefaultdomainName value to the local machine name
DefaultPassword value to the local user account password
DefaultUsername value to the local user that was setup in the script
ForceAutoLogon value to 1
LogonType value to 0
After this is done the computer reboots and should login as the local user automatically
but it doesn't. I've check the keys and prior to the reboot everything is correct. But after reboot its back to what it was before the script was run.
The weird thing is .. if I run the script again .. everything works.
Has anyone got any ideas why this is happening???
As I said if I run the same script again AFTER the reboot it set the registry entries with no problems and they stay after the 2nd reboot. So I'm thinking there something going on after the first reboot .. my first thoughts where Domain Group Policies but if that was the case then I would get the same results on the 2nd run of the script and reboot. I have another script that I run after this one that sets the local user startup to launch the VMClient and disables taskmanager , lockworkstation, and change password functions when they use ctlr-alt-del keys, which is done in the registry .. this work just fine.
My instinct says that it's a feature of ForceAutoLogon, rather than a problem with PowerShell's Set-ItemProperty.
ForceAutoLogon Article
Extract:
"In addition to logging on an account automatically, the ForceAutoLogon setting also logs you back on after you log off.
Setting the ForceAutoLogon setting effectively locks out all users aside from the one you are forcing."
After search and search for a resolution to my problem I finally found the issue.
One of the Forums I check mentions the AUTOLOGONCOUNT reg key .. when I looked at my computer it was not there.. after I had rebooted the computer .... This is a Corporate Computer and we use MDT to reimage the computers ... so it does autologon a couple of times. Which when it is done the count is set to zero and the autologon is set to zero .. but the AUTOLOGONCOUNT reg key is still there. so when I ran my script it would set it and at reboot .. unset it .. DUH me LOL .. any I re-image a computer and delete this key and ran my powershell script and all is good
thanks for those that gave me ideas
I want to know if there is an existing command or script to retrieve the Canonical Name Record (CNAME) for a given computer or server. I would like to use this via CMD/Powershell I don't mind if such command or script uses the Windows Registry Editor (regedit).
The hostname program/command should give you the DNS name of the local machine, whereas the shell command echo %COMPUTERNAME% should show you the NetBIOS name (which might be different).