my powershell script
:: Start :: Technology :: Computer & Internet
Page 1 of 1
my powershell script
Function Menu
{
Clear-Host
Do
{
Clear-Host
Write-Host -Object 'Please choose an option'
Write-Host -Object ''
Write-Host -Object '**********************'
Write-Host -Object ' Computer Options' -ForegroundColor Yellow
Write-Host -Object '**********************'
Write-Host -Object ''
Write-Host -Object '1. Get-Acl'
Write-Host -Object ''
Write-Host -Object '2. Unlock user account'
Write-Host -Object ''
Write-Host -Object '3. Ping computer/ip '
Write-Host -Object ''
Write-Host -Object '4. Get folder permissions '
Write-Host -Object ''
Write-Host -Object '5. Check if user is locked out '
Write-Host -Object ''
Write-Host -Object '6. Check acount lock status '
Write-Host -Object ''
Write-Host -Object '7. Ping computer/ip '
Write-Host -Object ''
Write-Host -Object '8. Reset account password'
Write-Host -Object ''
Write-Host -Object '9. Check if user is locked out '
Write-Host -Object ''
Write-Host -Object '10. Get Boot Time'
Write-Host -Object ''
Write-Host -Object '11. Hostname test'
Write-Host -Object ''
Write-Host -Object '12. Add system to domain'
Write-Host -Object ''
Write-Host -Object '13. Rename computer system '
Write-Host -Object ''
Write-Host -Object '14. Get users mailbox details'
Write-Host -Object ''
Write-Host -Object '15. Get your systems last 10 reboot times.'
Write-Host -Object ''
Write-Host -Object '16. Set Execution Policy'
Write-Host -Object ''
Write-Host -Object '17. ...'
Write-Host -Object ''
Write-Host -Object '18. ...'
Write-Host -Object ''
Write-Host -Object 'Q. Quit'
Write-Host -Object $errout
$Menu = Read-Host -Prompt '(1-18 or Q to Quit)'
switch ($Menu)
{
1
{
get-acl
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
2
{
$unlockname = Read-Host 'Enter name of locked account?'
Net user $unlockname /domain /active:yes
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
3
{
$pingpc = Read-Host 'Enter pc name or ip?'
ping $pingpc
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
4
{
RevertSpecificVMSnapshot
anyKey
}
5
{
$locked = Read-Host "Enter user name to check if locked out"
Get-ADUser $locked -Properties * | Select-Object LockedOut
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
6
{
$lockedout = Read-Host "Enter user name to check if locked out"
net user $lockedout /DOMAIN | FIND /I "Account Active"
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
7
{
$locked = Read-Host "Enter user name to check if locked out"
Get-ADUser $locked -Properties * | Select-Object LockedOut
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
8
{
$resetacct = Read-Host "Enter user account"
$resetpassword = Read-Host "Enter new password"
NET USER $resetacct $resetpassword /DOMAIN
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
9
{
$userstatus = Read-Host "Enter Server or PC name"
systeminfo /s $bootime | find "Boot Time"
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
10
{
$bootime = Read-Host "Enter Server or PC name"
systeminfo /s $bootime | find "Boot Time"
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
11
{
.\testhost.cmd
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
12
{
$addcomputer = Read-Host "Enter System name you wish to add to domain"
add-computer –domainname $addcomputer.example.com -Credential AD\adminuser -restart –force
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
13
{
$oldname = Read-Host "Enter System name you wish to rename"
$newname = Read-Host "Enter New System name"
Rename-Computer -Computer $oldname -NewName $newname -Reboot -Confirm:$false
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
14
{
$mailbox = Read-Host "Enter username to get mailbox details"
Get-Mailboxstatistics $mailbox
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
15
{get-eventlog system | where-object {$_.eventid -eq 6006} | select -first 10
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
16
{Set-ExecutionPolicy
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
Q
{
Exit
}
default
{
$errout = 'Invalid option please try again........Try 1-9 or Q only'
}
}
}
until ($Menu -eq 'q')
}
# Launch The Menu
Menu
{
Clear-Host
Do
{
Clear-Host
Write-Host -Object 'Please choose an option'
Write-Host -Object ''
Write-Host -Object '**********************'
Write-Host -Object ' Computer Options' -ForegroundColor Yellow
Write-Host -Object '**********************'
Write-Host -Object ''
Write-Host -Object '1. Get-Acl'
Write-Host -Object ''
Write-Host -Object '2. Unlock user account'
Write-Host -Object ''
Write-Host -Object '3. Ping computer/ip '
Write-Host -Object ''
Write-Host -Object '4. Get folder permissions '
Write-Host -Object ''
Write-Host -Object '5. Check if user is locked out '
Write-Host -Object ''
Write-Host -Object '6. Check acount lock status '
Write-Host -Object ''
Write-Host -Object '7. Ping computer/ip '
Write-Host -Object ''
Write-Host -Object '8. Reset account password'
Write-Host -Object ''
Write-Host -Object '9. Check if user is locked out '
Write-Host -Object ''
Write-Host -Object '10. Get Boot Time'
Write-Host -Object ''
Write-Host -Object '11. Hostname test'
Write-Host -Object ''
Write-Host -Object '12. Add system to domain'
Write-Host -Object ''
Write-Host -Object '13. Rename computer system '
Write-Host -Object ''
Write-Host -Object '14. Get users mailbox details'
Write-Host -Object ''
Write-Host -Object '15. Get your systems last 10 reboot times.'
Write-Host -Object ''
Write-Host -Object '16. Set Execution Policy'
Write-Host -Object ''
Write-Host -Object '17. ...'
Write-Host -Object ''
Write-Host -Object '18. ...'
Write-Host -Object ''
Write-Host -Object 'Q. Quit'
Write-Host -Object $errout
$Menu = Read-Host -Prompt '(1-18 or Q to Quit)'
switch ($Menu)
{
1
{
get-acl
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
2
{
$unlockname = Read-Host 'Enter name of locked account?'
Net user $unlockname /domain /active:yes
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
3
{
$pingpc = Read-Host 'Enter pc name or ip?'
ping $pingpc
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
4
{
RevertSpecificVMSnapshot
anyKey
}
5
{
$locked = Read-Host "Enter user name to check if locked out"
Get-ADUser $locked -Properties * | Select-Object LockedOut
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
6
{
$lockedout = Read-Host "Enter user name to check if locked out"
net user $lockedout /DOMAIN | FIND /I "Account Active"
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
7
{
$locked = Read-Host "Enter user name to check if locked out"
Get-ADUser $locked -Properties * | Select-Object LockedOut
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
8
{
$resetacct = Read-Host "Enter user account"
$resetpassword = Read-Host "Enter new password"
NET USER $resetacct $resetpassword /DOMAIN
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
9
{
$userstatus = Read-Host "Enter Server or PC name"
systeminfo /s $bootime | find "Boot Time"
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
10
{
$bootime = Read-Host "Enter Server or PC name"
systeminfo /s $bootime | find "Boot Time"
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
11
{
.\testhost.cmd
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
12
{
$addcomputer = Read-Host "Enter System name you wish to add to domain"
add-computer –domainname $addcomputer.example.com -Credential AD\adminuser -restart –force
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
13
{
$oldname = Read-Host "Enter System name you wish to rename"
$newname = Read-Host "Enter New System name"
Rename-Computer -Computer $oldname -NewName $newname -Reboot -Confirm:$false
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
14
{
$mailbox = Read-Host "Enter username to get mailbox details"
Get-Mailboxstatistics $mailbox
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
15
{get-eventlog system | where-object {$_.eventid -eq 6006} | select -first 10
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
16
{Set-ExecutionPolicy
write-host "Press any key to go back to menu..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
Q
{
Exit
}
default
{
$errout = 'Invalid option please try again........Try 1-9 or Q only'
}
}
}
until ($Menu -eq 'q')
}
# Launch The Menu
Menu
sunt- Number of posts : 145
Registration date : 2008-11-14
:: Start :: Technology :: Computer & Internet
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|