# How to deploy PS script via gpo

**URL:** <https://forums.powershell.org/t/how-to-deploy-ps-script-via-gpo/22287>\
**Category:** PowerShell Help\
**Created:** [May 12, 2023, 2:31pm UTC](https://forums.powershell.org/t/how-to-deploy-ps-script-via-gpo/22287 "2023-05-12T14:31:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehsahmed](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@ehsahmed](https://forums.powershell.org/u/ehsahmed)\
**Post date:** [May 12, 2023, 2:31pm UTC](https://forums.powershell.org/t/how-to-deploy-ps-script-via-gpo/22287/1 "2023-05-12T14:31:57Z")

</div>

This is my script need to push to our client machine from gpo.

# This script runs the FortiESNAC.exe command with the specified IP address argument

$ipAddress = “192.168.10.8”  
$fortiClientPath = “C:\Program Files\Fortinet\FortiClient\FortiESNAC.exe”

# Check if FortiClient path exists

if (Test-Path $fortiClientPath) {  
# Run the FortiESNAC command with the IP address argument  
& $fortiClientPath -r $ipAddress  
}  
else {  
Write-Host “FortiClient path not found: $fortiClientPath”  
}

---

<div class="post-metadata">

**Author:** ![ehsahmed](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@ehsahmed](https://forums.powershell.org/u/ehsahmed)\
**Post date:** [May 12, 2023, 2:33pm UTC](https://forums.powershell.org/t/how-to-deploy-ps-script-via-gpo/22287/2 "2023-05-12T14:33:29Z")

</div>

i have created the gpo policy and push but its not working in our environment, please help me and validate my powershell script.

---

<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:** [May 12, 2023, 3:17pm UTC](https://forums.powershell.org/t/how-to-deploy-ps-script-via-gpo/22287/3 "2023-05-12T15:17:01Z")

</div>

I would run your script manually to “validate” it. We don’t have your environment available to us, so that is up to you to validate. Also, you don’t share how you push your script through GPO, so after you’ve validated your script you may want to change the discussion to how you are pushing it out. Be sure to share details about what does happen vs what you expected to happen. (at that point it may not even be a powershell issue, so consider if this is the best site for it.) Finally, always post code and errors with the preformatted text option so that it can read easily and nothing happens to the characters.

Guide to formatting - [https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [February 10, 2024, 5:34pm UTC](https://forums.powershell.org/t/how-to-deploy-ps-script-via-gpo/22287/4 "2024-02-10T17:34:03Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
