Forum Discussion
using powershell within service possible?
Hi,
Have some powershell code to give us inventory of workspace and reports and run this in powershell.
Is it possibe to run powershell scripts directly in servicedesktop without having to run manually like this?
Thanks
3 Replies
- AnonymousNot applicable
Hi po,
You have to execute your PowerShell scripts from the IDE when developing or testing things out. Export it to a .CSV or table in a database, and go from there.
Reza Rad at RADACAD.com has a nice write-up of how to set this up, with decent intermediate explanations of the entire thing.
I strongly suggest you read, and try this approach.
When your script is finished, you can use things like Task Scheduler to automate this process. Here is a blog with info on how you can do that.
- poPost Prodigy
Hi,
Thanks for update.
Have ran online to get inventory and works online.
Can now look to scedule.
However, we are currently using
Login-PowerBI
and notice radacad uses get credentials but both involve online entry which won't be possible when schedule.
How can we pass username and password and login to power vbi via script without pop-up box?
Thanks
- AnonymousNot applicable
Hi po,
I use the snippet below in my own Audit Logs script, and pass to Task Scheduler. Make sure you use an app password from O365, to avoid having to deal with MFA.
##This is better for scheduled jobs $User = "[email protected]" $PWord = ConvertTo-SecureString -String "apppasswordhere" -AsPlainText -Force $UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PWord ###This will prompt the user for credential #$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session