Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $exitFile = [string]::Empty
- $dhcpFile = [IO.File]::OpenText('C:\Temp\dhcpd.define')
- while ($dhcpFile.Peek() -ge 0) {
- $dhcpLine = $dhcpFile.ReadLine()
- $namesFile = [IO.File]::OpenText('C:\Temp\hosts-glpi-win7-names-sorted.txt')
- while ($namesFile.Peek() -ge 0) {
- $namesLine = $namesFile.ReadLine()
- if($dhcpLine -Match " " + $namesLine + " ") {
- if($dhcpLine[0] -ne '#') {
- $dhcpLine = $dhcpLine.Insert(0, '#')
- }
- }
- ElseIf($dhcpLine -Match " " + $namesLine + "$") {
- if($dhcpLine[0] -ne '#') {
- $dhcpLine = $dhcpLine.Insert(0, '#')
- }
- }
- }
- $namesFile.Dispose()
- $exitFile = $exitFile + "`n" + $dhcpLine
- }
- $dhcpFile.Dispose()
- $exitFile | Out-File 'C:\Temp\exitDCHP.txt'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement