Day 13 Other
XML:
Powershell support XML, as XML is a language which works great for windows, and it’s like a platform independent, you can create a webpages using xml.
With Powershell we can use Export-Clixml cmdlet to convert an output to xml format.
Remoting:
It require PowerShell v2
Enable_remoting
help about_remote_troubleshooting
EnterPSSession -computer –computername
EnterPSSession -computer -computername (get‐content names.txt)
Email:
Email can be done using one of the following:
- Outlook
- .Net
- SNTP
- Outlook
$Outlook = New-Object .-com Outlook.Application
$Inbox = $Outlook.Session.GetDefaultFolder(6)
$Inbox.items | foreach { write-host $_.Subject }
- For .Net
System.Net.Mail
System.Net.Mail.MailMessage
System.Net.Mail.SmtpClient
System.Net.Mail.Attachment
$Email = New-Object System.Net.Mail.MailMessage( “Info@contoso.local”, “administrator@contoso.local”)
- SMTPClient
Coloring:
You can define coloring at the output as well
PS C:\> write-host -Fore Red “Powershell” -Back Green
More properties/methods:
If you see the get-member of any cmdlets you may get some properties/methods but that may not be complete to get the complete list of properties and methods use the Format List (fl) option with * .
|Fl*
Profile:
As you know if you declare any variable or script anything that will be valid (available ) until you are using the session, once you close the Powershell session your variables will be lost, to keep the variable or object for longer use, declare it at profile which loads at the time of Powershell start
To get the profile location there is a variable called “PROFILE”
PS C:\> variable profile |fl *
Name : PROFILE
Description :
Value : C:\Documents and Settings\<user>\My Documents\WindowsPowerS
hell\Microsoft.PowerShell_profile.ps1
Options : None
Attributes : {}
Generally profile will be at location
C:\Documents and Settings\<user>\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
*Will try to update it further.