Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Sean Smith
2022-06-21T22:33:38Z
I am at a loss on this.

PowerShell Scripts --> will set variables for username/passwords, data locations, log locations, log file names, etc. What is strange, when I run the script via PowerShell, it produces all of the files I am expecting to see. It will produce .log and .csv files based on the code. However, when I run the script via VisualCron 9.9.8, the script produces only the .log files and NOT the .csv files.

Does Visual Cron have issue with utilizing a piped call to "Export-CSV" (example: $snapsremove | Export-Csv $filelocation4 -NoTypeInformation)?

The way the script is constructed...I am unsure if it is actually running correctly. Any hints on how to vet this out? I may try support as well to see if there are any got-cha's I am missing.
Sponsor
Forum information
thomas
2022-06-22T10:43:41Z
Are the powershell version the same on the VC server and your local computer (if that is wehere you tested) ? Some features of Export-csv are only available on vertain PS vesions. You can check by running $PSVersionTable
Sean Smith
2022-06-22T14:46:39Z
Curious...
This is the server where i can run in PS and it exports without issue. Only when executed in VC does it not produce CSVs.
$PSVersionTable from the server running visual cron. This is where i am running the script from PS...
Name Value
---- -----
PSVersion 5.1.17763.2931
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.2931
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Sean Smith
2022-06-23T16:58:54Z
Per support, I attempted to create an "Execute" task instead of a "PowerShell" task. Results --> no difference. The script will only produce .log file when executed within VC. I am hoping i don't have to re-create it...but...if certain modules or commands are not fully functional, i guess i will have no choice. Any other suggestions out there? I can provide code example if that would be helpful.

2022-06-23 10_58_01-Window.png
Sean Smith
2022-06-23T17:30:09Z
I am thinking this is my hang up...

# vCenter logins and path to list of names
$appliance = Get-Content -Path "$DataLocation\vcsa.txt"
$user = "administrator@vsphere.local"
$pass = Get-Content -Path "$DataLocation\vcsa_pass.txt" | ConvertTo-SecureString
$mycredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $pass
snapcheck

When i run this with the PowerShell task type or the Execute task type, it doesn't like the crypto...
2022-06-23 11_29_05-Window.png

I think i will have to re-think how we do this and re-work it a bit...unless someone has a brilliant idea out there?
Sean Smith
2022-06-28T16:35:58Z
I think I got it!

Site that triggered an “ah ha”…
https://stackoverflow.co...onvertto-securestring-ke 

Comment:
You have to create the password string on the same computer and with the same login that you will use to run it.

I regenerated the secure password files with the same account that is running the job. All good now!
Scroll to Top