none
IE Trusted Zones

    Question

  • Hello, I've created a powershell script that will create a "Network Location".. I am wanting to push this out via a GPO. To be able to get this script run, I have to Internet Options,Security,Local intranet,sites  and add file://*.<domainname>/sysvol

    I have tried several different ways to get this to work with a gpo and have not been successful.   Any idea's or suggests?

    Thursday, October 20, 2016 12:39 PM

All replies

  • Hi LandLord,

    >>To be able to get this script run, I have to Internet Options,Security,Local intranet,sites  and add file://*.<domainname>/sysvol

    Besides of the above settings, I also suggest you check the Powershell script execution policies, by running: Get-ExecutionPolicy under powershell console to ensure that this script is allowed to be execution locally.

    Ps: using Set-ExecutionPolicy Unrestricted  also helpful.

    Or, you could check under the following GPO location under domain level GPO settings:

    Have a nice day!

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Friday, October 21, 2016 3:20 AM
    Moderator
  • Hello, thanks.. I did try that.. you can see what I have here.. the marked out info is *.<domainname>

    the script I am running is...

    Function AddNetworkLocation {

    <#
    .DESCRIPTION
        Creates a new Network Location.
     
    .PARAMETER Shortcutname
        The name of the Network place that appears in explorer
     
    .PARAMETER Path
        The path to the resource that you wish to use
     
    .EXAMPLE
         AddNetworkLocation -ShortcutName OHTEST -Path "\\Server\Path\To\Resource"

         Creates a network place called OHTEST that points to \\Server\Path\To\Resource
     
    .INPUTS
        None
     
    .OUTPUTS
        None
     
    .NOTES
        Author:  OH
        Credit for this code: https://social.technet.microsoft.com/Forums/scriptcenter/en-US/bd00d576-6096-4c8d-bd82-3c5853eb6675/create-shortcut-in-my-network-places-using-powershell?forum=ITCG
        Website: http://www.fearthemonkey.co.uk
        Github:  https://github.com/ozthe2
        Twitter: @ozthe2
    #>

        [CmdletBinding()]
           
        Param(             
            [PARAMETER(Mandatory=$True)]              
            [string[]]$ShortcutName,

            [PARAMETER(Mandatory=$True)]       
            [string]$Path
        )

        BEGIN {}

        PROCESS {
            $const_NETHOOD = 0x13
            $oApp = new-Object -com Shell.Application
            $oShell = new-Object -com Wscript.Shell

            $NetHood = ($oApp.Namespace($const_NETHOOD)).Self.Path
            $NetLocLocalPath = "$NetHood\$ShortcutName"

            if ( !(test-Path $NetLocLocalPath -pathType container) )
            {
             new-Item $NetLocLocalPath -type directory -force
             attrib "$NetLocLocalPath" +R
            }

            if ( !(test-Path "$NetLocLocalPath\Desktop.ini" -pathType leaf) )
            {
             $oFile = new-Item "$NetLocLocalPath\Desktop.ini" -type file -force
             add-Content $oFile "[.ShellClassInfo]"
             add-Content $oFile "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}"
             add-Content $oFile "Flags=2"
             attrib "$NetLocLocalPath\Desktop.ini" +H +S -A
            }


            if ( (test-Path "$NetLocLocalPath\target.lnk" -pathType leaf) )
            {
             $oLnk = $oShell.CreateShortcut("$NetLocLocalPath\target.lnk")
             $OldLnk = $oLnk.TargetPath

             if ($OldLnk -ne $Path)
             {
              $oLnk.TargetPath = $Path
              $oLnk.Save()
             }
            }
            else
            {
             $oLnk = $oShell.CreateShortcut("$NetLocLocalPath\target.lnk")

             $oLnk.TargetPath = $Path
             $oLnk.Save()
            }
           
            
        }#end process   
    }

    AddNetworkLocation -ShortcutName "Backups" -Path "\\Backups\ My Path"

    I've done a gpupdate /force several time and rebooted.. and I still can't get it to work

    Friday, October 21, 2016 2:44 PM
  • does the script complete when ran locally IE on the device outside of the GPO?
    Monday, October 31, 2016 8:40 PM