I'm trying to create a shortcut to run my PowerShell script. This works fine but not when it needs to load the Active directory module. I've searched everywhere, but couldn't find an answer. When adding the line 'import-module' it doesn't work anymore:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command import-module ActiveDirectory "& 'C:\MyScript.ps1' "
Thank you for your help.
#Requires -Module ActiveDirectory
line in your script. – brianary