Search found 14441 matches

by jvierra
Tue Jun 16, 2020 12:27 pm
Forum: PowerShell
Topic: Calling a function from within a dsc configuration issue
Replies: 8
Views: 1063

Re: Calling a function from within a dsc configuration issue

Some CmdLets won't work in DC o you will have to test.
by jvierra
Tue Jun 16, 2020 8:02 am
Forum: PowerShell
Topic: Calling a function from within a dsc configuration issue
Replies: 8
Views: 1063

Re: Calling a function from within a dsc configuration issue

You can call a CmdLet that is PS core. Any added functions will not be available unless you include them in teh DSC code.

Review the full documentation on DSC to see examples of how to work with external code.
by jvierra
Tue Jun 16, 2020 7:15 am
Forum: PowerShell
Topic: replace part of string with regular expression
Replies: 6
Views: 396

Re: replace part of string with regular expression

Here is one simple way to do this:

Code: Select all

$txt = "line 1
line 2
# replace starts here

# replace ends here
line 6
line 7
"
$txt -match '(?smi)(.*line 2)'
$p1 = $matches[1]
$txt -match '(?smi)(line 6.*)'
$p2 = $matches[1]
$p1 + $p2
by jvierra
Tue Jun 16, 2020 6:54 am
Forum: PowerShell
Topic: replace part of string with regular expression
Replies: 6
Views: 396

Re: replace part of string with regular expression

Replacing random text in a file with a regular expression is very difficult. We must have the exact conditions of the file contents at that location.

The basic technique is to do a multi\line trap then use that to replace the target.

Without a clear example this would be hard to describe.
by jvierra
Tue Jun 16, 2020 12:51 am
Forum: PowerShell
Topic: Calling a function from within a dsc configuration issue
Replies: 8
Views: 1063

Re: Calling a function from within a dsc configuration issue

You cannot refer to external functions o modules in a DSC. A DSC is run under the system ConfigMgr process and not in any user session.
by jvierra
Mon Jun 15, 2020 12:30 pm
Forum: PowerShell
Topic: XML Merge
Replies: 14
Views: 1050

Re: XML Merge

Have you tried this? $finalXml = "<root>" foreach ($file in $files) { [xml]$xml = Get-Content $file $finalXml += $xml.InnerXml } $finalXml += "</root>" ([xml]$finalXml).Save("$pwd\final.xml") This does NOT merge XML. It concatenates the contents of the files which is not what the word "merge" means...
by jvierra
Mon Jun 15, 2020 11:58 am
Forum: PowerShell
Topic: MsgBox Execution Query
Replies: 3
Views: 378

Re: MsgBox Execution Query

No. That is what "modal" means. A child form is modal to the parent. The parent is not executing. This is a limitation of forms in PowerShell due to the threading capability.

You can open a form in a new runspace and it will be modeless to the parent form as it runs in a new thread (runspace).
by jvierra
Mon Jun 15, 2020 11:55 am
Forum: PowerShell GUIs
Topic: Understanding CheckedListBox controls
Replies: 13
Views: 841

Re: Understanding CheckedListBox controls

Why set that? It is not clear to me why that would happen. Graphics card maybe?

Without a simple example there is no way to test your issue.
by jvierra
Sat Jun 13, 2020 5:54 pm
Forum: PowerShell GUIs
Topic: Timer Event Help
Replies: 22
Views: 1362

Re: Timer Event Help

An animated GIF does not require a timer. It blinks by itself. That is why it is called and "animated gif". Search a bit to get more info.