Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

I am not sure what i am doing wrong. PS function

$
0
0

<# Script to set a site into the trusted sites zone on a single workstation #> Function Trust-Site {<# .SYNOPSIS Trust-Site adds a registry to the a machine trusting a internet site. .DESCRIPTION Trusted site will add a site to the trusted site list using the registry. .PARAMETER ComputerName Enter Computer Name here. .PARAMETER Site Enter Site to be trusted here. .PARAMETER Type Enter Http Or Https. .EXAMPLE Trust-site -computername DIG123456 -site fakesite.abc -type http. .EXAMPLE Trust-site -computername DIG123456 -site fakesite.abc -type https. #> [CmdletBinding()] Param( [Parameter( Mandatory=$true, ValueFromPipeline=$True, HelpMessage= 'Enter the target computer name')][String[]]$ComputerName, [Parameter( Mandatory=$true, HelpMessage= 'Please enter the name of the site to be trusted' )][String]$Site, [Parameter( Mandatory=$true, HelpMessage= 'Please put in either HTTP or HTTPS' )][String]$Type ) Begin { if ($type -notlike 'http' -or 'https') {Throw 'Value for type was not correct, please enter http or https'} } Process { Foreach ($computer in $ComputerName) { Invoke-Command -ComputerName $computer -scriptblock { New-Item "hklm:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\$Site" New-ItemProperty "hklm:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\$Site" -name $type -value 2 -PropertyType DWORD } } } End{} } $Name = Read-host "Please enter the Target ComputerName" $Site = Read-Host "Please enter the Site name, be sure to omit http or https" $type = Read-Host "Please specify HTTP or HTTPS" Trust-Site -ComputerName $Name -Site $Site -Type $type Start-Sleep -Seconds 30

Please enter the Target ComputerName: XXXXXXX

Please enter the Site name, be sure to omit http or https: www.test.com Please specify HTTP or HTTPS: http Value for type was not correct, please enter http or https At C:\Users\CHILBURN\Desktop\Craig Test scripts\Working tools\trust-site.ps1:48 char:45+ if ($type -notlike 'http' -or 'https') {Throw 'Value for type was not correc ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : OperationStopped: (Value for type ...r http or https:String) [], RuntimeException+ FullyQualifiedErrorId : Value for type was not correct, please enter http or https




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>