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.

1
  • Added powershell tag, formatted code. Commented Oct 15, 2018 at 4:59

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.