Hi Ladi-1118
I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.
Issue:
Powershell to create logsearch in bulk for azure vm's to check lowdiskspace
Solution:
Will describe here how my setup is: First the VM's are connected with Insight metrics and loganalytic workspace. Also on the monitoring Data collection rule has been connected and showing Monitored under -->Monitoring-->Insight-->Virtual Machines. Then with powershell save this script as ps1. under c:\Scripts or what ever folder you need to navigate. Script reads also from file C:\Scripts\Vm\VMNames.txt --> put your vm names in on each line per vm.
Query is define to check for space logical disk when it fels under 10 percent checks every 15 minutes. I have pasted here as txt you need to change parameters as described inside the script.Alert_query_logicaldisk.txt
Hope this helps to anyone that needs the Alert query with loganalytics with Powershell automation.
If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.
Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.