Shorten my script


i have script sets 3 values in intranet sites (via gpo ps1 script)

in script,  have had enter same thing each setting.

is there way streamline script?

[code]

$domdomain = "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains"
$cocllocal = "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains\dom.local"
$bhub = "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains\dom.local\bhub"
$cityweb = 'hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains\cityweb'

remove-item $bhub -erroraction silentlycontinue -recurse
remove-item $domlocal -erroraction silentlycontinue -recurse
remove-item $cityweb -force -erroraction silentlycontinue -recurse


        $doesdomainexist = test-path $domdomain
                if(-not ($doesdomainexist -eq $true)) {

            set-location "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap"
            new-item domains -erroraction silentlycontinue
            set-location domains
    }

        $doesexist = test-path $domlocal
                if(-not ($doesexist -eq $true)) {

            set-location "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains"
            new-item dom.local -erroraction silentlycontinue
            set-location dom.local
            new-itemproperty . -name * -value 1 -type dword
    }
        $doesbellamyexist = test-path $bhub

    if(-not ($doesbellamyexist -eq $true)) {
        
            set-location "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains\dom.local"
            new-item bhub -erroraction silentlycontinue
            set-location bhub
            new-itemproperty . -name http -value 1 -type dword
    }
        $doeswebexist = test-path $cityweb
# entry not remove remove-item.  says access denied because

# in use.

                if(-not ($doeswebexist -eq $true)) {
    
            set-location "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains"
            new-item cityweb -erroraction silentlycontinue
            set-location cityweb
            new-itemproperty . -name http -value 1 -type dword
    }
                else {
            set-location "hkcu:\software\microsoft\windows\currentversion\internet settings\zonemap\domains"
            new-item cityweb -erroraction silentlycontinue
            set-location cityweb
            new-itemproperty . -name http -value 1 -type dword
    }

[/code]

thank you

terry


this link should help:

https://technet.microsoft.com/en-us/library/hh847829.aspx

it has many simple examples , links more specific help.


richard mueller - mvp enterprise mobility (identity , access)



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...