At the moment we are experiencing some issues with invoke Powershell after updating Studio to 22.4. Before the update all scripts were working fine. It only occurs on Studio, the QA machine that is updated to 22.4 has no problem.
Does anyone have an idea how to fix this issue? We have tried updating dependencies, restarting machines and reinstalling Studio.
The sp_url is : âhttps://xxxxxx.sharepoint.com/sites/xxxxxxxxâ
The sp_path is: âShared Documents/General/XXX Files/XXX/XX XX XXXâ
The temp_directory is: C:\Users\XXXXX\Documents\UiPath\xxxxx\xxxxx\Data\Temp"
It could be due to some spaces in the Sharepoint paths, but we canât find what is the issue. They were working fine in 21.4.
#Connecting to Sharepoint online through Client secrete key & Application ID
Connect-PnPOnline -Url $sp_url -ClientId âCLIENTIDâ -ClientSecret âSECRETâ -warningAction ignore
#Checking for Download from sharepoint
If ($DownloadorUpload.ToUpper() -eq âDOWNLOADâ)
{
#Get the folder from sharePoint
$Files = Get-PnPFolderItem -FolderSiteRelativeUrl $sp_path -ItemType File
#Get the each file from sharePoint folder
foreach($File in $Files)
{
Try {
#Downloading the files from sharepoint
Get-PnPFile -Url $File.ServerRelativeUrl -Path $temp_directory -FileName $File.Name -AsFile
}
Catch
{
#Setting the Status as false if not able to download
$Status = "False"
}
}
}
Thank you for the extra context. Could you still confirm the version of the System activity package (and whether downgrading/upgrading this package fixes the faulty behaviour)?
I have tried 21.4, 21.10 and 22.4 , all does not fix the behavior.
update: We know that the error is in: Get-PnPFile -Url $File.ServerRelativeUrl -Path $temp_directory -FileName $File.Name -AsFile
Wrote all variables as output and they look good (they work in ISE). One more thing we noticed, is when we ran the script twice, it was giving write errors in ISE. After putting -force behind the get-pnpfile command it was working fine , and then tried the same in UiPath where it is failing with and without -force
After juggling a bit with the Pnp Powershell versions (were on 1.0.9, now 1.0.10 and 1.0.35 implemented) we get the following again:
Invoke Power Shell DownloadAll: PowerShell command errors:
Could not load type âMicrosoft.Extensions.Logging.Abstractions.Internal.NullScopeâ from assembly âMicrosoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60â.
Could not load type âMicrosoft.Extensions.Logging.Abstractions.Internal.NullScopeâ from assembly âMicrosoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60â.
@alexandru@loginerror We have compared the 22.4 dll with the 21.4 dll (where the scripts still work) and see there is a difference,
is there a way to replace the dll to try if that works?
update: tried to create a nupkg package from the âoldâ dll and implemented that in the project. gives the same error. Going back to 21.4 studio version solves the issue,moving to 22.4 again gives the error
After it finishes and the files are copied, an error is thrown (see below). The fix is to set the TypeArgument to String . This might be the error that occurs.
Invoke Power Shell: Unable to cast object of type 'System.String' to type 'System.Management.Automation.PSObject'.
If the above doesnât fix your problem:
Make sure that the PS module used is compatible with the SharePoint version, the available modules are SharePointPnPPowerShellOnline, SharePointPnPPowerShell2019, SharePointPnPPowerShell2016, and SharePointPnPPowerShell2013.
Install SharePoint Server 20xx Client Components SDK on the running machine.
Send us both the Event Tracing file and the Studio Desktop log file so that we know exactly what the error is. Also, we need all the details about the context, e.g.: the SharePoint version, the complete script, any of the files that were copied, etc.
Thanks for the update.
Unfortunately we receive the same error with that script as well.
We use PnP.Powershell (last version 1.10.0) as the module because we are working with Sharepoint Online. Tried to install the Sharepoint Server 20XX client components but no luck.
The exact error is: Invoke Power Shell: Could not load type âMicrosoft.Extensions.Logging.Abstractions.Internal.NullScopeâ from assembly âMicrosoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60â.
We are using Sharepoint Online and try to download some Excel files (cannot share them because they are confidential, but it can be any file).
See the code below (disabled everything except connecting, and that is giving the error.
$sp_url = "URL"
$sp_path = "FOLDER"
$temp_directory ="TEMP"
$DownloadorUpload = "DOWNORUPLOAD"
$FileName = "FILENAME"
$Password = "SECRET"
$UserName = "CLIENTID"
#Connecting to Sharepoint online through Client secrete key & Application ID
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword
Connect-PnPOnline -Url $sp_url -Credentials $Cred
#Checking for Download from sharepoint
If ($DownloadorUpload.ToUpper() -eq "DOWNLOAD")
{
#Get the folder from sharePoint
#$Files = Get-PnPFolderItem -FolderSiteRelativeUrl $sp_path -ItemType File
#Get the each file from sharePoint folder
#foreach($File in $Files)
{
Try {
#Downloading the files from sharepoint
#Get-PnPFile -Url $File.ServerRelativeUrl -Path $temp_directory -FileName $File.Name -AsFile
}
Catch
{
#Setting the Status as false if not able to download
$Status = "False"
}
}
}
Last event properties in event viewer before it is stopped:
One more error I can see in the studio.project.log:
[WARN] [UiPath.Studio.Project.exe] [1] System.IO.IOException: Cannot locate resource âthemes/icons.xamlâ.
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse response)
at MS.Internal.WpfWebRequestHelper.GetResponseStream(WebRequest request, ContentType& contentType)
at System.Windows.ResourceDictionary.set_Source(Uri value)
at UiPath.Studio.Plugin.Workflow.Services.ActivityIconFinder.TryGetThemedActivitiesIconDictionary(String assemblyName)
Update: we moved all invoke powershell scripts to a start process solution with using PowerShell directly so we are not dependent anymore on the activity itself
Just to close this topic, even though it was a while ago and a workaround was already found.
Weâve done some research and these are our findings:
PnP.PowerShell is a open-source, community supported module with no official documentation. The minimum version required to run the module is 7.2 of PowerShell Core. Importing the module does not cause an error, but due to cmdlets in the module including unapproved verbs, the module will not load any cmdlets.
Moreover, the module has known dependency conflicts with multiple required modules of PowerShell and even with the SharePoint Server Client Components SDK, causing the module to not be loaded.
Suggestion on the official community forum would be to use:
This should allow PowerShell to choose a compatible version if it exists.
More information can be found at:
and
Also, on our end, the Invoke PowerShell activity will soon gain the option to select PowerShell execution mode, which might help here (but it is unfortunately not a guaranteed fix to this particular issue).