need help to copy file from windows to ubuntu wsl share,
i created the below code which works manually, the ubuntu Distribution subsystem gets installed as user and not system,
i need to copy the certificate file with PSADT from windows share to ubuntu share,
the below command works fine but how can i make it work while deploying using SCCM with PSADT? as we know SCCM executes this with system account i am curious if this logic will work or not?
i even need to check if ubuntu subsystem is installed or not then it should copy.
If your script works as user manually, try launching it as the user either with PSADT or ActiveSetup if applicable.
If you run PSADT as system you can launch things as the current user.
I created a Tip about your options here.
Please note that it refers to PSADT v3 functions and that you’ll have find the match V4 function names.
If you need to launch the script only when a user is logged in, consider ActiveSetup. That way you can install regardless if a user is logged-in or not.
The only issue i am facing is resolving the WSL share path inside the IF condition it’s not getting resolved can someone help on this? The Log is not written as the if condition not satisfied, but it is still copying the file to WSL share:
I am running it as system and tried admin as well and it is copying the file however it is not writing the log, I tried troubleshooting it and if condition always returning not found…. But it is executing the try block and copying the file… but no log entry if run using system or admin
What I am getting from you is:
1 - The PSADT log file is being created.
2 - NONE of the 3 Write-log lines listed above show up in the log file.
3 - The 2 Execute-Process lines listed above do work. (IOW: the files are copied)
4 - Other Write-log lines, before and after this block of code, do show up in the log file.
If the command within the If statement works then I see no reason why the Write-Log won’t work. You should probably check your PSADT configuration where you are writing log files and check for log files in both paths. In v3 the configuration is in the file AppDeployToolkitConfig.xml. Check both Toolkit_LogPath and Toolkit_LogPathNoAdminRights, it uses one of these depending on the rights of the user executing the script.
If you install ubuntu on windows you can access the fileshare with \\wsl.localhost or \\wsl$…… i tried \\wsl.localhost the file copy fails but with \\wsl$ it copies the file
Somehow if condition able to check the path of ubuntu subsystem but when it starts the wsl.exe session it ignores the write log or echo
Asked this to chatgpt and getting below response , so i will first check the session of wsl if its not running then will initiate it and then execute the remaining code
Your script is checking for the existence of $wslPath using Test-Path, but the issue is that Test-Path does not reliably detect WSL paths (\wsl$ shares) immediately after being accessed or created. Here is why this might be happening and how to fix it:
Possible Causes:
WSL Path Timing Issue:
Sometimes, the \wsl$\Ubuntu\usr\local\share\ca-certificates path is not immediately accessible after launching WSL, especially if WSL was not already running.
Permissions Issue:
Even if the path exists, Test-Path might fail if the current user doesnt have permission to access the \wsl$ share.
WSL Not Fully Initialized:
If WSL was not running before the script executed, it may take a moment to initialize, causing Test-Path to fail.