0

Output Function update the data in txt file

Function LogWrite
{
    Param ([string]$logstring)
    $Logfile = "C:\temp\$(gc env:computername).txt"
    $logstring | out-file $LogFile -Append
}

Function readonly {
    $user=whoami
    $out=(Get-Acl "C:\temp").Access | Select-Object IdentityReference,FileSystemRights
    $acl = Get-Acl "C:\temp"
    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($user,"FullControl","Allow")
    $acl.SetAccessRule($AccessRule)
    LogWrite $user,$out
}readonly

Function readonly updates data to function logwrite. It updates the results of whoami and system.object.

I need your help to update the results of $out.

Nic3500
  • 8,144
  • 10
  • 29
  • 40
dss.pisces
  • 15
  • 1
  • 7

1 Answers1

0

LogWrite expects one string parameter, but you're calling it with two parameters. You can either use string formatting to merge $whoami and $out via LogWrite "User=$user, Out= $out". Or you change LogWrite that it takes an array of strings [String[]] (explained in this stackoverflow link).

Hope that helps.

Moerwald
  • 10,448
  • 9
  • 43
  • 83