|
|
|
@ -24,19 +24,70 @@ function prompt {
|
|
|
|
|
|
|
|
|
|
'[{0}@{1} {2}]{3} ' -f $username,$computername,$cwd,$delimiter
|
|
|
|
|
}
|
|
|
|
|
function Get-BetterADUser {
|
|
|
|
|
function Get-BADUser {
|
|
|
|
|
param (
|
|
|
|
|
[Parameter(Mandatory=$true,
|
|
|
|
|
Position=0)]
|
|
|
|
|
[string]
|
|
|
|
|
$SearchTerm,
|
|
|
|
|
|
|
|
|
|
[string]
|
|
|
|
|
$Server = $env:USERDNSDOMAIN
|
|
|
|
|
$Server = $env:USERDNSDOMAIN+':3268'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$filter = 'UserPrincipalName -like "*{0}*" -or Name -like "*{0}*"' -f $SearchTerm
|
|
|
|
|
|
|
|
|
|
Get-ADUser -Filter $filter -Server $Server
|
|
|
|
|
Get-ADUser -Filter $filter -Server $Server @args
|
|
|
|
|
}
|
|
|
|
|
function Get-BADGroup {
|
|
|
|
|
param (
|
|
|
|
|
[Parameter(Mandatory=$true,
|
|
|
|
|
Position=0)]
|
|
|
|
|
[string]
|
|
|
|
|
$SearchTerm,
|
|
|
|
|
|
|
|
|
|
[string[]]
|
|
|
|
|
$Properties = @('Description','ManagedBy'),
|
|
|
|
|
|
|
|
|
|
[string]
|
|
|
|
|
$Server = $env:USERDNSDOMAIN+':3268'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$filter = 'Name -like "*{0}*" -or Description -like "*{0}*"' -f $SearchTerm
|
|
|
|
|
|
|
|
|
|
Get-ADGroup -Filter $filter -Properties $Properties -Server $Server @args
|
|
|
|
|
}
|
|
|
|
|
function Get-BADComputer {
|
|
|
|
|
param (
|
|
|
|
|
[Parameter(Mandatory=$true,
|
|
|
|
|
Position=0)]
|
|
|
|
|
[string]
|
|
|
|
|
$SearchTerm,
|
|
|
|
|
|
|
|
|
|
[string[]]
|
|
|
|
|
$Properties = @('Description','ManagedBy'),
|
|
|
|
|
|
|
|
|
|
[string]
|
|
|
|
|
$Server = $env:USERDNSDOMAIN+':3268'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$filter = 'Name -like "*{0}*" -or Description -like "*{0}*"' -f $SearchTerm
|
|
|
|
|
|
|
|
|
|
Get-ADComputer -Filter $filter -Properties $Properties -Server $Server @args
|
|
|
|
|
}
|
|
|
|
|
function Get-BADPrincipalGroupMembership {
|
|
|
|
|
param (
|
|
|
|
|
[Parameter(ValueFromPipeline)]
|
|
|
|
|
[Microsoft.ActiveDirectory.Management.ADAccount]
|
|
|
|
|
$ADObject
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
process {
|
|
|
|
|
write-host $ADObject
|
|
|
|
|
$server = $ADObject.DistinguishedName.Split(',DC=')[-2,-1] -join '.'
|
|
|
|
|
|
|
|
|
|
$ADObject | Get-ADPrincipalGroupMembership -Server $server
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function Get-Feierabend {
|
|
|
|
|
param (
|
|
|
|
@ -72,6 +123,26 @@ function fsh {
|
|
|
|
|
|
|
|
|
|
Enter-PSSession @PSBoundParameters @args
|
|
|
|
|
}
|
|
|
|
|
function watch {
|
|
|
|
|
param (
|
|
|
|
|
[int]$n = 2,
|
|
|
|
|
|
|
|
|
|
[Parameter(Mandatory,
|
|
|
|
|
Position = 0)]
|
|
|
|
|
$ScriptBlock
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
while ($true) {
|
|
|
|
|
$o = Invoke-Command -ScriptBlock $ScriptBlock
|
|
|
|
|
|
|
|
|
|
Clear-Host
|
|
|
|
|
'Watching {'+$ScriptBlock+'} '+(Get-Date)
|
|
|
|
|
''
|
|
|
|
|
$o
|
|
|
|
|
|
|
|
|
|
Start-Sleep -Seconds $n
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#check for old version
|
|
|
|
|
if($PSVersionTable.PSVersion.Major -le 5){
|
|
|
|
|