Powershell scriptlogon GPO- It runs only for domain admin, but not domain users

Akiyo Hiroshi 1 Reputation point
2021-04-10T23:15:26.547+00:00

Hi everyone,

I have a Powershell script runs as users login. I have tested , It runs if the user is domain admin, but does not run for domain users.

Set-ExecutionPolicy Bypass

$username=$env:username

$date=Get-Date -format M-d-yy-HHmm

$Source= "\FServer\Sharefolder\$username"

$Destination="\Fserver2\Sharefolder2\$username"

$Log="\Fileserver2\Sharefolder3\Temp\Log-$username-$date.txt"

If ($Source-and $Destination) {

ROBOCOPY $Source $Destination "/E" "/S" "/SEC" "/XD" "AppData" /LOG+:log

}

any help is appreciated.

86499-image.png

Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
{count} votes

3 answers

Sort by: Most helpful
  1. Akiyo Hiroshi 1 Reputation point
    2021-04-10T23:17:41.913+00:00

    another important question,

    The parameter section: -executionpolicy Bypass, is that correct ?

    0 comments No comments

  2. MotoX80 36,291 Reputation points
    2021-04-11T03:18:24.58+00:00

    How do you know that it's not running? Have the script create a transcript into a local temp folder and see if you are just getting some error.

    Start-Transcript -path c:\Windows\temp\RemoveSig.log
    ... the script code goes here 
    Stop-Transcript
    
    0 comments No comments

  3. Anonymous
    2021-04-12T07:11:02.15+00:00

    Hello @Akiyo Hiroshi ,

    Thank you for your posting here.

    If you logon one domain PC using one domain account, can you run the script successfully with this domain user?

    Best Regards,
    Daisy Zhou

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.