You did say the execution policy is set correctly, so do you mean
unrestricted? When you run the script as the user, is it local or on a
server? When it’s run as a logon script, it’s on Sysvol I assume. That
could be the difference if the execution policy is remote signed.



*From:* listsadmin@lists.myitforum.com [mailto:
listsadmin@lists.myitforum.com] *On Behalf Of *James Rankin
*Sent:* Tuesday, October 27, 2015 5:58 PM
*To:* ntsys...@lists.myitforum.com
*Subject:* [NTSysADM] PowerShell setting registry value via logon script



I am trying to use a PowerShell logon script to change the user’s profile
state value in the Registry to simulate a roaming profile (to allow Cookies
to be saved properly in IE11). To do this I need the user’s SID, which I am
pulling out and then setting the Registry value.



The script I am using is this



$USERSID = ([Security.Principal.WindowsIdentity]::GetCurrent()).User.Value

$regpath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\
$USERSID"

$name = "State"

Set-ItemProperty -Path $regpath -Name $name -Value "20"



When I run this as the user (logged in), it works perfectly. The Execution
Policy is set correctly and also I have used a script to change the
Registry permissions at computer startup so that the user has Full Control
of the target key.



However, when run as a GPO Logon Script the value is never set. Am I
missing something here about how PowerShell logon scripts execute? If I use
a third-party piece of software (AppSense EM) to do this at logon, it also
works perfectly.



It’s a Windows Server 2012 R2 system running XenApp 7.6 FP3 that I am
trying to execute this on, for the record.



TIA,







*James Rankin*

EUC Director | HTG TaloSys | 07809 668579 | ja...@htguk.com

One Trinity Green, Eldon Street, South Shields, Tyne & Wear, NE33 1SA

Tel: 0191 481 3489

Email address: i...@talosys.co.uk

Website: www.talosys.co.uk

[image: phpy9YoGNAM]

Reply via email to