run powershell script as administrator?

Man of Honour
Joined
30 Oct 2003
Posts
13,255
Location
Essex
yep working, it moved IP from static to DHCP.

do i have to run set-execution unrestricted first on every PC ?

Its a local policy (group policy) on the machine. You can change it on a per machine basis. On a machine reboot the policy will be set back.

You can set a group policy for all the machines to allow the code or set the policy at the beginning of the script and set it back at the end.
 
Soldato
OP
Joined
29 Jul 2003
Posts
7,666
thats more work than change the IP to DHCP via the control panel.

shame there is no real quick way for this.

but thanks guys :)
 
Man of Honour
Joined
30 Oct 2003
Posts
13,255
Location
Essex
could do but the manager said we must ensure every PC must be on DHCP so will the deployment work? we'll never know

So you can do this in command prompt:

PowerShell.exe -ExecutionPolicy Bypass -File .runme.ps1

Or what I would do is set them all to dhcp in group policy and lock it down so it sticks. Do you have access to a domain controller? Also in DHCP don't you have a ton of reservations for the fixed IPs? This sometimes isn't as simple as wack em all onto dhcp. How many nodes are we talking? How is DHCP made up and is the address poll big enough to service the nodes? What about redundancy if a domain controller goes down? Do you split across a couple of dhcp servers hosting half of the range each?

Also you should be able to see if a machine is on DHCP or fixed according to the lease in DHCP, take a look at the image below, the highlighted line is a reservation on a fixed address, if you don't reserve the fixed addresses in the same range you will end up with a lot of bad addresses in DHCP (perhaps this is the problem).

Edit this is bad advice:
If you just set a reservation on the bad address and delete the lease you should get whatever device is on that fixed address claim the reservation. Actually scrap that I think you need the unique ID (mac address) to make a reservation in the first place.

But you can remove the fixed address from the scope of dhcp and then query dns with nslookup to see what is on that address, but really rather than scripting it on every machine this should be dealt with in group policy because stuff like this is exactly what group policy is there for.

 
Last edited:
Soldato
OP
Joined
29 Jul 2003
Posts
7,666
hi vince thanks again

i dont have the access to DC from home, will have to wait till monday

im confused by what you said "But you can remove the fixed address from the scope of dhcp"

every PCs are issued a static IP address by manual input rather than they have been issued a static IP by deployment.

edit: approx 2300 PC's at 5 centres to be move to DHCP. im responsible for 1 centre with approx 470 PC's
 
Man of Honour
Joined
30 Oct 2003
Posts
13,255
Location
Essex
hi vince thanks again

i dont have the access to DC from home, will have to wait till monday

im confused by what you said "But you can remove the fixed address from the scope of dhcp"

every PCs are issued a static IP address by manual input rather than they have been issued a static IP by deployment.

edit: approx 2300 PC's at 5 centres to be move to DHCP. im responsible for 1 centre with approx 470 PC's

You will really need to check what is responsible for DHCP and what your range is. The first question I have is have "head office" given you a DHCP server address to use or already configured dhcp on your estate? If not and it's just down to you to get everything onto dhcp then you are going to have to have a good understanding of how the network is made up, is it a single subnet, multiple /24 ranges on vlans? Really only you know if you have enough knowledge about how the network works right now to determine how you want to distribute and manage dhcp.

There is a post in this technet forum (second post) that explains how to set up a stratup script and deploy it using group policy and it does it better than I can. You should make use of the admin tools at your disposal and in a domain environment pushing out startup or logon scripts over group policy is the right way to get this done quickly and effectively. We had a similar one last weekend and migrated our dhcp, dns, fsmo roles etc onto new 2016 domain controllers and demoted our old 2008r2 estate.

https://social.technet.microsoft.co...indows-2008-r2-group-policy?forum=winserverGP
 
Soldato
OP
Joined
29 Jul 2003
Posts
7,666
thanks for the post

the network manager designed the network and configured the vlans for each floors and 3 domains, wifi too. (wifi devices are on DHCP). all PC's are issued with static IP corresponding to the hostname and floor.

no problem with networking at all. recently the manager have asked us to move all PC's from static to DHCP....DHCP leasing are already setup ready for the PCs to be taken off the static IP

i just need a very simple way to get the PC's on DHCP. if it was that simple, he would do it via the group policy.

edit: its not my role to dealing with the networking. i'm just an IT techie that responsible for a site with 470 PC's. i have access to the DC. and group policies too.
 
Man of Honour
Joined
30 Oct 2003
Posts
13,255
Location
Essex
thanks for the post

the network manager designed the network and configured the vlans for each floors and 3 domains, wifi too. (wifi devices are on DHCP). all PC's are issued with static IP corresponding to the hostname and floor.

no problem with networking at all. recently the manager have asked us to move all PC's from static to DHCP....DHCP leasing are already setup ready for the PCs to be taken off the static IP

i just need a very simple way to get the PC's on DHCP. if it was that simple, he would do it via the group policy.

edit: its not my role to dealing with the networking. i'm just an IT techie that responsible for a site with 470 PC's. i have access to the DC. and group policies too.

All good then, nothing wrong with just using the powershell script :)
 
Back
Top Bottom