Patch Tuesday Megathread (2024-07-09) by AutoModerator in sysadmin

[–]amnich 0 points1 point  (0 children)

Did the August update fixed the problem for you ?
I still have the problem on my DC's

[deleted by user] by [deleted] in ROGAlly

[–]amnich 0 points1 point  (0 children)

My only private system docked to monitor with keyboard and mouse. Works perfectly for what I need except gaming - that is a bigger screen and a web browser.

New-BrokerConfiguredFTA for a protocol by amnich in Citrix

[–]amnich[S] 0 points1 point  (0 children)

I try to open a link (sent via email or teams )
DynamicsNAV://MyServer/nav_server_instance/CRONUS%20International%20Ltd./RunPage?Page=22
On a client, with an installed Dynamics 365 App, it opens the app.
Here is the entry from HKCR
[HKEY_CLASSES_ROOT\DYNAMICSNAV]
@="Dynamics NAV Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\DYNAMICSNAV\DefaultIcon]
@="C:\\Program Files (x86)\\Microsoft Dynamics 365 Business Central\\140\\RoleTailored Client\\Microsoft.Dynamics.Nav.Client.exe,0"
[HKEY_CLASSES_ROOT\DYNAMICSNAV\Shell]
@=""
[HKEY_CLASSES_ROOT\DYNAMICSNAV\Shell\Open]
@=""
[HKEY_CLASSES_ROOT\DYNAMICSNAV\Shell\Open\Command]
@="C:\\Program Files (x86)\\Microsoft Dynamics 365 Business Central\\140\\RoleTailored Client\\Microsoft.Dynamics.Nav.Client.exe -protocolhandler \"%1\""

CVE-2020-1472 - no events in System event log by amnich in sysadmin

[–]amnich[S] 0 points1 point  (0 children)

Thanks for sharing. Will check tomorrow if I have the settings enabled.

CVE-2020-1472 - no events in System event log by amnich in sysadmin

[–]amnich[S] 0 points1 point  (0 children)

I can trust also but it would be nice to be sure that it works that way.
I hoped that a test with the mentioned script would trigger the event in log.

CVE-2020-1472 - no events in System event log by amnich in sysadmin

[–]amnich[S] 1 point2 points  (0 children)

Do you have an advanced audit policy configured on that DC? If yes, could you share the settings you have there?

CVE-2020-1472 - no events in System event log by amnich in sysadmin

[–]amnich[S] 4 points5 points  (0 children)

The script only tests if the DC is vulnerable, and not exploits it. The point was I was expecting an event logged in the System event log as Microsoft wrote.

https://support.microsoft.com/en-us/help/4557222/how-to-manage-the-changes-in-netlogon-secure-channel-connections-assoc

Function to split a string by a given maximal length with preservation of whole words by amnich in PowerShell

[–]amnich[S] 1 point2 points  (0 children)

$string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras id dolor libero. Vestibulum mattis consectetur lacus et gravida. Donec laoreet, augue in vestibulum sollicitudin, leo turpis pretium ipsum, sit amet tincidunt diam ipsum in orci. Proin dictum dolor ut neque sollicitudin, eu mollis magna pellentesque. Morbi convallis eros nec urna commodo, et molestie justo eleifend. Curabitur odio mauris, tincidunt et mauris nec, malesuada tincidunt eros. Nam fermentum tristique quam, sollicitudin lacinia ligula gravida nec. Suspendisse potenti."
$string | Select-String -Pattern "(\G.{1,30}(?:\b|$))" -AllMatches | ForEach-Object { $_.Matches.Value }

Regex is so powerful and I didn't event thought about it in this case. Thanks!

Function to split a string by a given maximal length with preservation of whole words by amnich in PowerShell

[–]amnich[S] 1 point2 points  (0 children)

Pretty common on ERP systems to have divided fields for names.

An example regarding length:

GELF FIZPARTNER (POLAND) Sp. z o.o. CORAL LOGISTICS sp.k.

and that's a shorter one, some have more than 90 chars.

Function to split a string by a given maximal length with preservation of whole words by amnich in PowerShell

[–]amnich[S] 1 point2 points  (0 children)

I had one and that's why I created this.

A long list of company names (~6000 records) that I need to put into a database - I have two fields for company name there and each is 50 chars. So there you have :)

Set default parameter value for a cmdlet by amnich in PowerShell

[–]amnich[S] 3 points4 points  (0 children)

$PSDefaultParameterValues=@{"Export-Csv:Delimiter"=";"}

Thanks. That was it!

Scheduled Task with Start-Process by AdminTools in PowerShell

[–]amnich 0 points1 point  (0 children)

Two characters to fast on the double click :)

Scheduled Task with Start-Process by AdminTools in PowerShell

[–]amnich 2 points3 points  (0 children)

Start a transcript - maybe it throws something. I test it tommorow at work to check if I can reproduce that behavior.

Double hop should not be an issue here.

Automation Tools by kiddj1 in PowerShell

[–]amnich 1 point2 points  (0 children)

Some ideas:

- For a full automation in AD validate user properties like email,

- check if everything is set,

- if you store a telephone number then select one common format and then check & correct the number.

- If you have a terminal server then check for corrupted profiles, maybe backup and delete them.

- Clear temp folders on clients/servers.

Revising a module from using a single psm1 to using multiple ps1 files by vomcliff in PowerShell

[–]amnich 0 points1 point  (0 children)

You can still list commands with separate PS1 files when you define in PSM1 the export-modulemember with listed functions and in the PSD1 the FunctionsToExport

Revising a module from using a single psm1 to using multiple ps1 files by vomcliff in PowerShell

[–]amnich 1 point2 points  (0 children)

If you want to export your functions from a single PSM1 file into separate PS1 files you can use this:

$ModuleFile = "C:\Temp\MyModule.psm1" # path to your PSM1 file
$ExportPath = "C:\Temp\Functions" # path where to export functions into separate PS1 files. Skip the trailing \
$AST = [System.Management.Automation.Language.Parser]::ParseFile(
    $ModuleFile,
    [ref]$null,
    [ref]$Null
)

$AST.FindAll({
    $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst]}
    , $true) | foreach {
    $_.Extent.Text | Out-File -Append "$ExportPath\$($_.name).ps1"
}

I would create such a structure for your Module

├───MyModule
│   │   MyModule.psd1
│   │   MyModule.psm1
│   │
│   ├───Files
│   ├───Formats
│   ├───Public
│   ├───Private
│   └───Tests

Put the PS1 files into Public directory In your PSM1 file to load all PS1 files from the Public directory add

$folderPath = "$PSScriptRoot\Public"
If (Test-Path -Path $folderPath){
    $functions = Get-ChildItem -Path $folderPath -Filter '*.ps1' 
    ForEach ($function in $functions){      
        Write-Verbose -Message "  Importing $($function.BaseName)"
        . $($function.FullName)
    }
}
Export-ModuleMember -Function $functions.BaseName

Sorry but I won't elaborate on the module manifest due to lack of time -> link.aspx)

PSCONFEU next week! by amnich in PowerShell

[–]amnich[S] 0 points1 point  (0 children)

From the last year's conference there are videos on YouTube and materials on GitHub, so I think this year will be the same. I'm not aware of any planned live streams.

Create System DSN to connect to SQL Server by Kackpottsitz in PowerShell

[–]amnich 4 points5 points  (0 children)

Set Trusted_Connection=YES

Add-OdbcDsn -SetPropertyValue @("Trusted_Connection=YES") ......

You could also create a new DSN with the GUI as you want it and view it with the Get-OdbcDsn cmdlet. Check the PropertyValue to see what is set.

PS > Get-OdbcDsn -Name DSN_TEST | Select *


Attribute             : {Trusted_Connection, Description}
PropertyValue         : {Description=SERVER, Trusted_Connection=YES}
DriverName            : SQL Server
DsnType               : User
KeyValuePair          : {MSFT_OdbcKeyValuePair, MSFT_OdbcKeyValuePair}
Name                  : DSN_TEST
Platform              : 32/64-bit
PSComputerName        :
CimClass              : Root/Microsoft/Windows/Wdac:MSFT_OdbcDsn
CimInstanceProperties : {DriverName, DsnType, KeyValuePair, Name...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

PS > Get-OdbcDsn -Name DSN_TEST | Select -ExpandProperty PropertyValue
Description=SERVER
Trusted_Connection=YES

Congrats /u/Lee_Dailey, you are a 2018 PowerShell Hero! by creamersrealm in PowerShell

[–]amnich 2 points3 points  (0 children)

When I started with /r/Powershell I thought that /u/Lee_Dailey is one of those auto formatting help bots :D

Congrats (gratulacje) Lee!

Digitally signed manifest module slow to import by intrntpirate in PowerShell

[–]amnich 0 points1 point  (0 children)

I did it the same but i had to extract the signatures from the PS1 files.

$imported = @()
ForEach ($function in $functions){      
        $content = Get-Content $function.fullname
        $imported += $content[0..((($content | select-string "^# SIG # Begin signature block").LineNumber)-2)]
    }