Posted in Windows Powershell | No Comment | 59 views | 22/05/2013 16:59
In this sample script, I use SCVMM 2012 to get virtual machine list.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| $Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
$VMInfo = Get-VM $Server
$VMHost = $VMInfo.VMHost
$VMHostName = $VMHost.Name
$VMHostGroup = $VMHost.VMHostGroup
if ($VMInfo.PassThroughDisks)
{
$PassThroughDisk = "True"
}
else
{
$PassThroughDisk = "False"
}
if ($VMHostGroup -like "All Hosts\*")
{
Add-Content -Value $Server -Path C:\Servers.txt
Add-Content -Value $VMHostName -Path C:\VMHosts.txt
Add-Content -Value $PassThroughDisk -Path C:\PassThroughDisks.txt
}
} |
Also you can filter specific Host Groups like in this sample.
Posted in Windows Powershell | No Comment | 31 views | 22/05/2013 16:45
You can get ready and retry queue’s of Exchange Server with this script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| $ExchangeHost = "ExCas01"
$ExchangeServer = Get-ExchangeServer -Identity $ExchangeHost
# Integers
[int]$ExchangeActiveConnections = 0;
[int]$ExchangeRetryQueue = 0;
[int]$ExchangeMessageQueue = 0;
[int]$ExchangeActiveQueue = 0;
[int]$HostMessageQueue = 0;
[int]$HostRetryQueue = 0;
# Get Mail Queue
if ($ExchangeServer.IsHubTransportServer -eq $True)
{
# Message Queue
$MessageQueue = Get-Queue -Server $ExchangeHost | Where {$_.Status -eq "Ready" -and $_.MessageCount -gt "0"}
# Sum Message Queue
Foreach ($Queue in $MessageQueue)
{
[int]$HostMessageQueue = [int]$HostMessageQueue + [int]$Queue.MessageCount
}
# Retry Queue
$RetryQueue = Get-Queue -Server $ExchangeHost | Where {$_.Status -eq "Retry" -and $_.MessageCount -gt "0"}
# Sum Retry Queue
Foreach ($Queue in $RetryQueue)
{
[int]$HostRetryQueue = [int]$HostRetryQueue + [int]$Queue.MessageCount
}
# Exchange Queue
[int]$ExchangeRetryQueue = [int]$ExchangeRetryQueue + [int]$HostRetryQueue
[int]$ExchangeMessageQueue = [int]$ExchangeMessageQueue + [int]$HostMessageQueue
[int]$ExchangeActiveQueue = [int]$ExchangeActiveQueue + [int]$HostRetryQueue + [int]$HostMessageQueue
} |
You can add multiple Exchange hosts to an array, it’ll just query Hub Transport servers. It only support Exchange Server 2010.
Posted in Windows Powershell | No Comment | 29 views | 22/05/2013 15:30
In this sample, I’ll show you how to get active Exchange Server CAS connections via PowerShell:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| $ExchangeHost = "ExCas01"
$ExchangeServer = Get-ExchangeServer -Identity $ExchangeHost
# Get Connections
if ($ExchangeServer.IsClientAccessServer -eq $True)
{
# OWA Connections
$HostOWAConnections = (Get-Counter "\MSExchange OWA\Current Unique Users" -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
# RPC Connections
$HostRPCConnections = (Get-Counter "\MSExchange RpcClientAccess\User Count" -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
# POP3 Connections
$HostPOP3Connections = (Get-Counter "\MSExchangePop3(1)\Connections Current" -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
# IMAP Connections
$HostIMAPConnections = (Get-Counter "\MSExchangeImap4(1)\Current Connections" -ComputerName $ExchangeHost).CounterSamples[0].CookedValue
# Exchange Connections
[int]$ExchangeActiveConnections = [int]$HostOWAConnections + [int]$HostRPCConnections + [int]$HostPOP3Connections + [int]$HostIMAPConnections
} |
You can loop this script to get real time connection statistics.
Posted in Windows Powershell | No Comment | 25 views | 22/05/2013 14:17
This is an example script for PoSHServer to query cluster names via HTTP get request.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| # Check Remote PowerShell Session
$CheckPSSession = Get-PSSession -ComputerName S0134CloudVMM04
if (!$CheckPSSession)
{
#$SecurePassword = ConvertTo-SecureString "Password_Here" -AsPlainText -Force
#$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "Domain\Username", $SecurePassword
#$Session = New-PSSession -Computername VMMHost2012 -Credential $Credentials
$Session = New-PSSession -Computername VMMHost2012
}
else
{
$Session = $CheckPSSession
}
# Get Virtual Machine Name
$VMName = $PoSHQuery.VM
# Get Virtual Machine Details Function
Function Get-InterVMDetails
{
Param ($Session, $VMName)
Invoke-Command -Session $Session -ArgumentList $VMName -ScriptBlock {
param($VMName)
$CheckModule = Get-Module -Name virtualmachinemanager -EA SilentlyContinue
if (!$CheckModule)
{
Import-Module -Name virtualmachinemanager -EA SilentlyContinue
}
$VMDetails = Get-SCVirtualMachine "$VMName"
$VMHost = $VMDetails.VMHost
$VMHostDetails = Get-SCVMHost "$VMHost"
$VMHostCluster = $VMHostDetails.HostCluster
$VMHostCluster.Name
}
}
# Get VM Details
if ($VMName)
{
$VMDetails = Get-InterVMDetails -VMName $VMName -Session $Session
}
# Output Web Interface
@"
$($VMDetails)
"@ |
Save this script as “getclustername.ps1″. Put it into PoSHServer homedirectory. After that you can query like this:
http://localhost:8080/getclustername.ps1?vmname=My_VM_Name |
You can query any information like this via PowerShell remoting.
Posted in Windows Powershell | 1 Comment | 464 views | 23/04/2013 16:55
Hello,
PoSHStats for Exchange Server v2.2 is almost ready!
I’m releasing latest version for tests. Please let me know if you find any bugs etc.
Main Screenshot:

Example of Exchange Host Reporting:

Example of Mailbox Database Reporting:

Example of User Mailbox Reporting:

It has a nice limit information bar :)

Also you can see service status of Exchange hosts:

This is not the final version of PoSHStats.
There will be more features for Exchange but I think this version is enough for many enterprises.
Tested with 3000 mailboxes, everything seems ok. First time setup will take about 5-10 minutes depends on your environment.
First download setup:
Install setup.exe. After installation, open PowerShell and:
1
2
| Import-Module PoSHStats
Start-PoSHStats |
Give your hostname (like reports.poshstats.net or 192.168.2.1) and port number, then you are free to go.
Thanks for using PoSHStats.
Yusuf.
Posted in Windows Server | 1 Comment | 98 views | 14/04/2013 17:28
Boot into command prompt with Windows Server 2008 R2 DVD.
1
2
3
4
| C:\
cd windows\system32
ren utilman.exe utilman.exe.bak
copy cmd.exe utilman.exe |
Change windows password by using Utilman (Windows Key + U) on logon screen.
net user Administrator NewPassword |
After that, you should revert changes.
Posted in Windows Server | No Comment | 1,071 views | 11/04/2013 15:49
You can disable “Restrict each user to a single session” on Windows Server 2008 by using “Remote Desktop Session Host Configuration”. But that tool is not available on Windows Server 2012. So we should disable it from local policy to enable 2 sessions at the same time.
Open run and type “gpedit.msc” for Local Group Policy. Go to:
Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Connections

Simply disable “Remote Desktop Services users to single remote desktop session” option.
After that you will be able to connect your server with 2 different session.
|