Installing Windows Server Backup on Windows Server 2012 R2
Windows Server Backup is not installed by default. You can use the Add Features Wizard in Server Manager to install it. After you use install Windows Server Backup, you can click Windows Server Backup on the Administrative Tools menu to manage backup operations, and you can use Wbadmin.exe to run backup commands from the command line.
You must also install the Windows PowerShell feature on the same computer to run Windows Server Backup command-line tools. If the Windows PowerShell feature is not installed when you select Command-line Tools during Windows Server Backup installation, you are prompted to install...
Last week I needed to export vmware.log files.
In the normal way you can read using putty client or download log using Datastore Browser.
But you also can download logs using PowerCLI.
to do it, we using cmdlet Copy-DatastoreItem
Copy-DatastoreItem <Object> <Object>]
To find the location of a virtual machine run this script:
get-vm MyVirtualMachine| Get-Datastore |Select name
Connect to Datastore using New-PSDrive cmdlet and change location to VM folder using Set-Location cmdlet.
New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root "\"
To display list log files, simple run ls *.log
At this point we can begin copy files from Datastore to local computer:
Copy-DatastoreItem -Item *.log -Destination...
Powershell : Count Members of a AD Group
As System Administrator, In many cases you need to count members of AD group.
The Get-ADGroupMember cmdlet gets the members of an Active Directory group. Members can be users, groups, and computers.
$users = Get-ADGroupMember -Identity 'Group Name'
Powershell - Windows Environment variables list
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs.
Get Environment variables list using Powershell
To get a list of variables we use the following command:
Get-ChildItem Env | Sort- Name
Get-ChildItem ENV | Sort Name
and result see like that :
Example 1: System root
Example 2: ALL USERS PROFILE
Example 3: PROCESSOR_ARCHITECTURE
How to: Unlock Active-Directory Users Account via PowerShell
First, open PowerShell in administrator right.
Import Module Active-Directory
Run command Search-ADAccount - LockedOut
If there are any locked accounts, they will be shown like the following example:
To unlock account(s), add Unlock-ADAccount parameter to basic command
Search and unlock all account in domain
Search-ADAccount -LockedOut | Unlock-ADAccount
Limit the search to a specific OU,
Search-ADAccount -SearchBase "OU=Users,OU=Skepper,DC=MyDomain,DC=net" -LockedOut | Unlock-ADAccount
Limit search to Users Only
Search-ADAccount -UsersOnly -LockedOut | Unlock-ADAccount
As system administrator in Microsoft environments you may need to send SMTP email via PowerShell.
In this article I'll explain how to do this easily by using cmdlet “Send-MailMessage”. you can read more about this cmdlet here.
Please note: This command is supported by PowerShell version 2 or higher.
$smtp = "smtp server, IP or FQDN"
$to = "Mail Recipient"
$from = "from email"
$subject = "subject"
$body = "body email"
$Attch = "Attachment file"
Send-MailMessage -smtp $smtp -to $to -from $from -subject $subject -body $body -Attachments $Attch
$smtp = "SMTP.BB.AA.COM"
$to = "ExAdmin@bb.aa.com"
$from = "System@bb.aa.com"
$subject = "DB Status Report"
$body = "Attached DB Status for week 22"
$Attch = "C:\DB.log"
Send-MailMessage -smtp $smtp -to...
How to: Get all Power-off VMs by using PowerCLI.
This Guide will guide you how to detect all Power-off VMs (vmware).
Some time we put VM in power off mode and never touch them any more,
after some month we wave a list of VMs in POwer-off mode,
There's nothing wrong, but if the space shortage begins to form we will have to delete the irrelevant.
We can identify by looking in vSphere client,
#Blue icon - Power Off
#Green icon - Power On
At Situation we want to get more information, such as disk size of each server, we going to using PowerCLI script:
Get-VM | where...
Get Uptime Info via PowerShell Script
This script How much time system is up ,Hours, Minutes and Secends
So, you need to know how many time your system is up,
Here a little PowerShell script that showing this info.
$wmi = Get-WmiObject -class Win32_OperatingSystem
$LBTime = $wmi.ConvertToDateTime($wmi.Lastbootuptime)
$uptime = New-TimeSpan $LBTime $(get-date)
Write-Output "$($uptime.days) Days $($uptime.hours) Hours $($uptime.minutes) Minutes $($uptime.seconds) Seconds"
simple and effective :-)