PowerShell 7 ile Linux uzerinde Basit Get-User Fonksiyonu

Linux uzerinde bir cok islemi farkli komutlarla elbette yapabilirsiniz ancak PowerShell catisi altinda bazi yonetimsel gorevleri konsolide etmeyi sevdigim icin bu basit fonksiyonu da sizlerle paylasmak istedim. Birden fazla linux komutunu tek PS fonksiyonunda birlestirmek hem kolay hem de Pratik oldu. Get-User isimli fonksiyonu siz de asagidaki gibi kullanabilirsiniz. Ben Ubuntu 18.04 uzerinde denedim, basarili oldu.
[crayon]
function Get-User{
param(
[string]$User
)
$user = $User
$user1 = get-content /etc/passwd | where{$_ -like “$user*”}
write-host “————————————————————————” -foregroundcolor red
write-host “Basic information for $user ” -foregroundcolor green
$user1
write-host “————————————————————————” -foregroundcolor red
$user2 = groups $user
write-host “Groups that $user belongs to” -foregroundcolor green
$user2
write-host “————————————————————————” -foregroundcolor red
$user3 = lslogins -u $user
write-host “Detailed information of the user: $user” -foregroundcolor green
$user3
write-host “————————————————————————” -foregroundcolor red
$user4 = lastlog -u $user
write-host “Last log information of the user: $user” -foregroundcolor green
$user4
}
[/crayon]

Leave a Reply