How to execute powershell scrip on deploying with EBS on IIS after staging folder has been moved to wwwroot ?

0

Hello, I'm trying to execute a specific powershell script on an instance of a windows server running IIS afetr that the 'staging' folder has been moved to the 'wwwroot' folder whle deploying with EBS. I have the following content in a 'script.config' in the .ebextensions of the app I'm deploying (as .zip) :

--- 

files: 
  ? "C:\\script-to-be-executed.ps1"
  : 
    content: |
        $path_to_media = "C:\inetpub\wwwroot\media"
        
        mkdir $path_to_media
        

container_commands: 
  99_set_rights_and_mount: 
    command: "powershell -NoProfile -ExecutionPolicy Bypass -file C:\\\\script-to-be-executed.ps1 *> C:\\log.txt"

When doing this, the script is executed while the process is still working in the 'staging' folder used when deploying. And afterward, the content of the 'staging' folder is moved to 'wwwroot' and everithing in it is crushed by the content of the 'staging' folder. I need that script (which is just an example, not the real work I need to do) to be executed after the move of the content of the 'staging' folder.

Thank you very much

已提問 1 年前檢視次數 320 次
1 個回答
0

Hi there,

I understand that you are facing some difficulties with using a specific Power Shell script on your instance.

An option worth looking at would be to implement the Start - Sleep logic to your script to delay the execution of the second part in your script. More information can be found below.

Start-Sleep - https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/start-sleep?view=powershell-7.3

I hope you find the above information helpful.

Have a nice day!

AWS
支援工程師
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南