PowerShell : Useful Commands
A collection of commands and scripts I've found useful when working with Windows PowerShell.
oracle miscconfigurationintermediate
by OracleDba
14 views
A collection of commands and scripts I've found useful when working with Windows PowerShell.
12345678
PS C:\> Set-ExecutionPolicy Unrestricted
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
PS C:\>123456789
$smtpServer = "smtp.example.com"
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "[email protected]"
$msg.ReplyTo = "[email protected]"
$msg.To.Add("[email protected]")
$msg.subject = "Test Mail"
$msg.body = "This is a test mail."
$smtp.Send($msg)123456789
if(get-process | ?{$_.path -eq "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"}){
# The process is running, so do something.
Write-Host "FireFox is running!"
}
if(get-process firefox){
# The process is running, so do something.
Write-Host "FireFox is running!"
}123456789101112
PS C:\> get-process firefox
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
276 44 110232 94772 315 1.39 3176 firefox
PS C:\>
PS C:\> stop-process -name firefox -force
PS C:\> stop-process -id 3176 -forcePlease to add comments
No comments yet. Be the first to comment!