Powershell Create Object

From Michael's Information Zone
Jump to navigation Jump to search

Filesystem Security

[1][2] Let's create an access object that can be used to update an ACL from the get-acl cmdlet.

$newrule=New-Object System.Security.AccessControl.FileSystemAccessRule($newname,$FileSystemRights,$InheritanceFlags,$PropagationFlags,$AccessControlType)

Other Types

[3]

$FirstName = Read-Host "Enter your First Name"
$LastName = Read-Host "Enter your Last Name"
$Shift = Read-Host "Enter your shift"
$Exmerge = Read-Host "Enter the amount of  Exmerges"
$MessageTrackers = Read-Host "Enter the amount of  MessageTrackers"

New-Object -TypeName PSCustomObject -Property @{    
    FirstName = $FirstName
    LastName = $LastName     
    Shift = $Shift
    Exmerge = $Exmerge
    MessageTrackers = $MessageTrackers
    Date = $ConCurrent
    } | Export-Csv C:\Users\Profile\Desktop\TestOutput_$((Get-Date).ToString('MM-dd-yyyy-hh-mm-ss')).csv -NoTypeInformation