To help you better we need some information from you.
*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.206
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.22000.0
PowerShell version(s): Tried 5.1 & 7.2
*** Please add details and screenshots as needed below. ***
DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
I have an array of JSON objects imported from a file into a variable, I am trying to remove one of the objects from the variable. I have tried various options as below and they all work when I test them in VSCode but it doesnt seem to work in Powershell Studio.
I have tried filtering the record and replacing the current variable as well as make a new variable with filtered results, again none work in Studio but all work in VSCode.
e.g.1
$newCon = $nc | Where-Object { $_ -ne $deleteRecord }
e.g.2
foreach ($c in $nc)
{
if ($c -ne $deleteRecord)
{
$newCon += $c
}
}
Remove object from an array
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Remove object from an array
Without the full script, I cannot determine what is wrong. Debugging may help you identify the problem.
You also may find the following helpful:
https://www.sapien.com/blog/2014/11/18/ ... owershell/
You also may find the following helpful:
https://www.sapien.com/blog/2014/11/18/ ... owershell/
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.