Question [Fonction] Activer les logs Powershell

Plus d'informations
il y a 4 mois 1 semaine #30646 par Laurent Dardenne
The following PowerShell functions let you enable and disable the system-wide transcription policies.
function Enable-PSTranscription {
  #https://devblogs.microsoft.com/powershell/powershell-the-blue-team/
[CmdletBinding()]
  param(
    $OutputDirectory,
    [Switch] $IncludeInvocationHeader
  )

    # Ensure the base path exists
    $basePath = "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription"
    if (-not (Test-Path $basePath))
    { New-Item $basePath -Force > $NULL}

    # Enable transcription
    Set-ItemProperty $basePath -Name EnableTranscripting -Value 1

    # Set the output directory
    if($PSCmdlet.MyInvocation.BoundParameters.ContainsKey("OutputDirectory"))
    { Set-ItemProperty $basePath -Name OutputDirectory -Value $OutputDirectory }

    # Set the invocation header
    if($IncludeInvocationHeader)
    { Set-ItemProperty $basePath -Name IncludeInvocationHeader -Value 1 }
}

function Disable-PSTranscription {
  Remove-Item HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription -Force -Recurse
}

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.078 secondes
Propulsé par Kunena