Hello,
I am processing large amount of Graph calls using powershell script block - 500K in my case. I want to process script blocks in batches. My ForEach-Object loop is defined inside class, say Library, in method, say ExportItems. Library.ExportItems call global function named Log([string]text). Method can successfully use it, however Parallel block cannot.
Steps to reproduce
using module .\logger.ps1
class SPOLibrary {
[void]ExportItems (
[string]$OutputFileName
) {
try {
# MAIN: process loaded queue
$this.Process( $OutputFileName)
}
finally {
}
}
[void]Process (
[string]$OutputFileName
){
[int]$_batchSize = 20
1..$_batchSize | ForEach-Object -Parallel {
# NOW here is the global function that is not visible to this block
Log "text"
}
}
Expected behavior
global functions should be visible within script block
Actual behavior
Environment data
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.19603
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Hello,
I am processing large amount of Graph calls using powershell script block - 500K in my case. I want to process script blocks in batches. My ForEach-Object loop is defined inside class, say Library, in method, say ExportItems. Library.ExportItems call global function named Log([string]text). Method can successfully use it, however Parallel block cannot.
Steps to reproduce
Expected behavior
Actual behavior
Environment data