Mar 17 2022 10:33 AM
Hi,
I'm new to powershell and I've been developing some simple scripts to check stuff in our internal network. Now I want to set a task to run a script every morning at 9am. So I got the script ready and tested, and configured the task schedule pointing to that script and run it, but there is not execution.
So I started to read about possible debug for my case. While reading, I've decided to write a very simple script, just to check if it would run from the task scheduler, and it doesn't run.
This is the script:
# Write date to a txt file
get-date > C:\Temp\debug.txt
# Open a pop-up window
powershell -WindowStyle hidden -Command "& {[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Teste','WARNING')}"
If I run this script from Powershell ISE everything goes well, file is created and the pop-up opens.
If I run this script directly from powershell using "powershell c:\Temp\Test.ps1" it opens the pop-up window, but the file is not created.
If I run this script from task scheduler nothing happens, even though the event says it ran.
So I'm really missing something here.
Can anyone point me out in the correct direction?
Thanks
Mar 17 2022 10:53 AM
Mar 21 2022 06:00 AM
Mar 21 2022 06:08 AM
Solution@dmarquesgn You can use this at the start of the script to set TLS to 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Mar 21 2022 06:13 AM
Mar 21 2022 06:18 AM
Mar 21 2022 06:08 AM
Solution@dmarquesgn You can use this at the start of the script to set TLS to 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12