# Learning powershell

**URL:** <https://forums.powershell.org/t/learning-powershell/15139>\
**Category:** PowerShell Help\
**Created:** [October 23, 2020, 3:37pm UTC](https://forums.powershell.org/t/learning-powershell/15139 "2020-10-23T15:37:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcas19](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@mcas19](https://forums.powershell.org/u/mcas19)\
**Post date:** [October 23, 2020, 3:37pm UTC](https://forums.powershell.org/t/learning-powershell/15139/1 "2020-10-23T15:37:45Z")

</div>

I am in college learning powershell for the first time. I was given an assignment to use powershell to add some users to an active directory. I managed to cobble together a very rudimentary script that did the job, but missed a part of the lab that said to give all the user passwords as well. I deleted the users, made a minor edit to the script to add the passwords, then tried again. However, when I tried I was given an error saying that the “cannot be loaded because running scripts is disabled on this system”. I ran the get-executionpolicy -list command and found

MachinePolicy Restricted  
UserPolicy Restricted  
Process Undefined  
CurrentUser Undefined  
LocalMachine Unrestricted

&nbsp;

If anyone could tell me what went wrong and how to fix it that would be greatly appreciated. This was the script I used

&nbsp;

$newuserlist=Import-Csv “C:\userexport.csv”

foreach ($user in $newuserlist) {

$fullname=$user.FullName

$password=“P@ssw0rd”

New-ADUser -passthru -DisplayName $FullName -Name $FullName -AccountPassword (ConvertTo-SecureString $password -AsPlainText -Force)

}

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [October 23, 2020, 4:51pm UTC](https://forums.powershell.org/t/learning-powershell/15139/2 "2020-10-23T16:51:43Z")

</div>

Change your execution policy to remotesigned. If you’re running as admin, it will change the localmachine and currentuser policy by default unless you’ve previously defined the currentuser, which it doesn’t appear you did. You can change just the currentuser scope by adding -Scope CurrentUser If you’re not running as admin specify the currentuser scope.

---

<div class="post-metadata">

**Author:** ![mcas19](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@mcas19](https://forums.powershell.org/u/mcas19)\
**Post date:** [October 23, 2020, 5:04pm UTC](https://forums.powershell.org/t/learning-powershell/15139/3 "2020-10-23T17:04:49Z")

</div>

I am signed in as admin. When I try changing any of the policies I get this error

Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined  
at a more specific scope. Due to the override, your shell will retain its current effective execution policy of Restricted.

The thing is I don’t know what policy is overriding it. Like I said in the original post, the only thing I did after my script worked the first time is delete the created users and add the password commands. I didn’t touch anything about policies

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [October 23, 2020, 6:31pm UTC](https://forums.powershell.org/t/learning-powershell/15139/4 "2020-10-23T18:31:49Z")

</div>

Which one didn’t change? Currentuser is my bet. Add -Scope Currentuser

---

<div class="post-metadata">

**Author:** ![mcas19](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@mcas19](https://forums.powershell.org/u/mcas19)\
**Post date:** [October 24, 2020, 7:18am UTC](https://forums.powershell.org/t/learning-powershell/15139/5 "2020-10-24T07:18:13Z")

</div>

I tried adding that as well and got the same message

PS C:\Users\Administrator\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser  
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined  
at a more specific scope. Due to the override, your shell will retain its current effective execution policy of Restricted. Type  
“Get-ExecutionPolicy -List” to view your execution policy settings. For more information please see “Get-Help Set-ExecutionPolicy”.  
At line:1 char:1

- Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
- 

```auto

```

- CategoryInfo : PermissionDenied: (🙂 [Set-ExecutionPolicy], SecurityException
- FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

---

<div class="post-metadata">

**Author:** ![dhrubbharali](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dhrubbharali/32/47_2.png) [@dhrubbharali](https://forums.powershell.org/u/dhrubbharali)\
**Post date:** [October 25, 2020, 5:13am UTC](https://forums.powershell.org/t/learning-powershell/15139/6 "2020-10-25T05:13:08Z")

</div>

Use Set-executionpolicy Unrestricted and try to run the code.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/learning-powershell/15139/7 "2024-05-16T20:28:41Z")

</div>


