smurfexe Posted September 27, 2022 Share Posted September 27, 2022 hi. im trying to setup a DHCP server with powershell using variables. but with variables it doesnt work and without it does. is it possible that i cant use varibles? this is the script so far. $DHCPNAME = "Scope171186" $DHCPSTARTRANGE = "172.16.2.100" $DHCPENDRANGE = "172.16.2.151" $DHCPSUBNETMASK = "255.255.255.0" $defaultgateway = "172.16.2.10" $DNSSERVER = "172.16.2.10" Install-WindowsFeature "DHCP" –IncludeManagementTools add-DhcpServerV4Scope -Name "DHCP Scope" -StartRange $DHCPSTARTRANGE -EndRange $DHCPENDRANGE -SubnetMask $DHCPSUBNETMASK Quote Link to comment Share on other sites More sharing options...
0phoi5 Posted April 14 Share Posted April 14 Is that the literal script, or are you using functions? Note that variables within a function will not be available outside of a function unless set to global. Also, are you sure that's correct syntax? When setting a variable, I don't believe you place a $ at the beginning, only when you are calling it, so; VARIABLE = "blabla" echo $VARIABLE Quote Link to comment Share on other sites More sharing options...
Irukandji Posted April 14 Share Posted April 14 Why are you bumping? Posted September 27, 2022 Quote Link to comment Share on other sites More sharing options...
dark_pyrro Posted April 14 Share Posted April 14 I have to ask; what's the time limit to not answer an open thread in the forums? Hunting down people that tries to answer questions really annoys me sometimes. If the thread hasn't been active for 8 years, I get it, but otherwise... who cares if it tries to add to the understanding of a topic. And, the $ char is totally OK to use when defining/populating a variable using PowerShell. In bash (or such) on the other hand, you use it without the $ char when it's defined/populated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.