PS1 script doesn't work on Windows 11 22H2


jinkazama

Member
Local time
4:11 PM
Posts
14
OS
Windows 11
I have a working ps1 script to install windows app (i use it on windows 10) but if i use it on Windows 11 22H2 it opens and close after 1 second.
I've enabled Developer mode but it doesn't work, someone can help me to use it?
I think it's Powershell Execution Policy issue.
Thank you
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
I have a working ps1 script to install windows app (i use it on windows 10) but if i use it on Windows 11 22H2 it opens and close after 1 second.
I've enabled Developer mode but it doesn't work, someone can help me to use it? Thank you
Do you run it as admin?
 

My Computers

System One System Two

  • OS
    Win11 All /Debian/Arch
    Computer type
    Laptop
    Manufacturer/Model
    ASUSTeK COMPUTER INC. TUF Gaming FX705GM
    CPU
    2.20 gigahertz Intel i7-8750H Hyper-threaded 12 cores
    Motherboard
    ASUSTeK COMPUTER INC. FX705GM 1.0
    Memory
    24428 Megabytes
    Graphics Card(s)
    Intel(R) UHD Graphics 630 / NVIDIA GeForce GTX 1060
    Sound Card
    Intel(R) Display Audio / Realtek(R) Audio
    Monitor(s) Displays
    Integrated Monitor (17.3"vis)
    Screen Resolution
    FHD 1920X1080 16:9
    Hard Drives
    2 SSD SATA/NVM Express 1.3
    WDS500G2B0A-00SM50 500.1 GB
    WDCSDAPNUW-1002 256 GB
    PSU
    19V DC 6.32 A 120 W
    Cooling
    Dual Fans
    Mouse
    MS Bluetooth
    Internet Speed
    Fiber 1GB Cox -us & ADSL Bouygues -fr
    Browser
    Edge Canary- Firefox Nightly
    Antivirus
    Windows Defender
    Other Info
    VMs of Windows 11 stable/Beta/Dev/Canary
    VM of XeroLinux- Arch based & Debian 12
  • Operating System
    Windows 11 Insider Canary
    Computer type
    Laptop
    Manufacturer/Model
    ASUS X751BP
    CPU
    AMD Dual Core A6-9220
    Motherboard
    ASUS
    Memory
    8 GB
    Graphics card(s)
    AMD Radeon R5 M420
    Sound Card
    Realtek
    Monitor(s) Displays
    17.3
    Screen Resolution
    1600X900 16:9
    Hard Drives
    1TB 5400RPM
Open the PowerShell and execute the .ps1 script from PowerShell to see error message.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
First, open Powershell (not the script)... navigate to the directory that has the script and run it manually from there, that way the window wont just flash and go away, you may find an error message that explains what's going on... If that doesn't work, I have a few ideas, but if you don't mind, could you post the contents of the file so we can test it on our systems? (Obviously remove any personal info, keys, etc.)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro β
    Computer type
    Laptop
    Manufacturer/Model
    HP Pavilion Laptop 15-eg0070wm
    CPU
    Intel® Core™ i7-1165G7
    Memory
    32 GB DDR4-3200 SDRAM
    Graphics Card(s)
    Intel® Iris® Xᵉ Graphics
    Screen Resolution
    1920x1080
    Hard Drives
    2TB PCIe® NVMe™ M.2 SSD
  • Operating System
    macOS Ventura
    Computer type
    PC/Desktop
    Manufacturer/Model
    Apple iMac 27" 5K (2017)
    CPU
    3.4 GHz Quad-Core Intel Core i5
    Memory
    40 GB 2400 MHz DDR4
    Graphics card(s)
    Radeon Pro 570 4 GB
    Monitor(s) Displays
    27" 5K, 34" UW
    Screen Resolution
    Mon 1: 5120 × 2880 Mon 2: 2560 x 1080
    Hard Drives
    32GB NVME, 1TB SSD
I got this error:
Code:
SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
Then i've googled and i've found this solution, in a administrator Powershell i run
Code:
Set-ExecutionPolicy RemoteSigned
and after this i can run ps1 directly from file.
Is there a way to apply this remotesigned command via script?
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
With that error, you have two choices... You can remove/alter the security feature that restricts the type of Powershell script you can run or the safer option which is to self-sign your script.

Just so you know, when you ran: Set-ExecutionPolicy RemoteSigned that 'sticks' so you don't need to run it again next time. It's a toggle, when you set the Policy to any of the options.

My suggestion would be to follow the instructions on this site (about Signing - PowerShell) to learn how to self-sign scripts that you have written. (Do NOT self-sign scripts you find online unless you understand what they are doing so you don't cause any problems.)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro β
    Computer type
    Laptop
    Manufacturer/Model
    HP Pavilion Laptop 15-eg0070wm
    CPU
    Intel® Core™ i7-1165G7
    Memory
    32 GB DDR4-3200 SDRAM
    Graphics Card(s)
    Intel® Iris® Xᵉ Graphics
    Screen Resolution
    1920x1080
    Hard Drives
    2TB PCIe® NVMe™ M.2 SSD
  • Operating System
    macOS Ventura
    Computer type
    PC/Desktop
    Manufacturer/Model
    Apple iMac 27" 5K (2017)
    CPU
    3.4 GHz Quad-Core Intel Core i5
    Memory
    40 GB 2400 MHz DDR4
    Graphics card(s)
    Radeon Pro 570 4 GB
    Monitor(s) Displays
    27" 5K, 34" UW
    Screen Resolution
    Mon 1: 5120 × 2880 Mon 2: 2560 x 1080
    Hard Drives
    32GB NVME, 1TB SSD
I wanna share my experience, i've found a way to run single script without discalimers and prompt windows, just create a .bat file
Code:
powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "scriptfilename.ps1"
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop

Latest Support Threads

Back
Top Bottom