Categories
Sponsors
Archive
Blogroll
Badges
Community
|
Posted in Windows Powershell | 1 Comment | 2,465 views | 31/07/2013 16:48
If you need to store a secure password in PowerShell, you can use this process.
First, you should create a hash from your password:
1
2
3
| $Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
$SecureString = ConvertTo-SecureString "Your_Password" -AsPlainText -Force
$StandardString = ConvertFrom-SecureString $SecureString -Key $Key |
$Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
$SecureString = ConvertTo-SecureString "Your_Password" -AsPlainText -Force
$StandardString = ConvertFrom-SecureString $SecureString -Key $Key
After that you can use $StandarString output in your scripts. Just you need to convert it back to secure string:
1
2
| $Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
$SecureString = ConvertTo-SecureString $StandardString -Key $Key |
$Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
$SecureString = ConvertTo-SecureString $StandardString -Key $Key
That’s it. I hope that helps.
Posted in Virtual Machine Manager, Windows Powershell, Windows Server | No Comment | 2,456 views | 26/07/2013 15:56
You can set User Role Quota for each Cloud Profile in SCVMM 2012 SP1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| $UserRoles = "BackOffice","CallCenter","ExchangeTeam"
foreach ($UserRole in $UserRoles)
{
$UserRole = Get-SCUserRole $UserRole
$Clouds = "DMZ Cloud","Prod Cloud","Test Cloud"
foreach ($Cloud in $Clouds)
{
$MyCloud = Get-SCCloud $Cloud
$CPUCount = (Get-VM -Cloud $MyCloud | Where UserRole -like "$UserRole" | Measure-Object -Property CPUCount -Sum).Sum
$Memory = (Get-VM -Cloud $MyCloud | Where UserRole -like "$UserRole" | Measure-Object -Property Memory -Sum).Sum
$VMCount = (Get-VM -Cloud $MyCloud | Where UserRole -like "$UserRole").Count
[int]$NewCPUCount = [int]$CPUCount + 40;
[int]$NewMemory = [int]$Memory + 81920;
[int]$NewVMCount = [int]$VMCount + 10;
Get-SCUserRoleQuota -UserRole $UserRole -Cloud $MyCloud | Set-SCUserRoleQuota -CPUCount $NewCPUCount -MemoryMB $NewMemory -VMCount $NewVMCount
}
} |
$UserRoles = "BackOffice","CallCenter","ExchangeTeam"
foreach ($UserRole in $UserRoles)
{
$UserRole = Get-SCUserRole $UserRole
$Clouds = "DMZ Cloud","Prod Cloud","Test Cloud"
foreach ($Cloud in $Clouds)
{
$MyCloud = Get-SCCloud $Cloud
$CPUCount = (Get-VM -Cloud $MyCloud | Where UserRole -like "$UserRole" | Measure-Object -Property CPUCount -Sum).Sum
$Memory = (Get-VM -Cloud $MyCloud | Where UserRole -like "$UserRole" | Measure-Object -Property Memory -Sum).Sum
$VMCount = (Get-VM -Cloud $MyCloud | Where UserRole -like "$UserRole").Count
[int]$NewCPUCount = [int]$CPUCount + 40;
[int]$NewMemory = [int]$Memory + 81920;
[int]$NewVMCount = [int]$VMCount + 10;
Get-SCUserRoleQuota -UserRole $UserRole -Cloud $MyCloud | Set-SCUserRoleQuota -CPUCount $NewCPUCount -MemoryMB $NewMemory -VMCount $NewVMCount
}
}
That will set on all profiles on $UserRoles array.
Posted in Virtual Machine Manager, Windows Powershell, Windows Server | No Comment | 2,443 views | 26/07/2013 12:06
You can change UserRoles of virtual machines on SCVMM 2012 SP1 with following command:
1
2
3
4
5
6
| $VMs = Get-VM | Where Name -like "*CALL*" | Where UserRole -eq $Null
foreach ($VM in $VMs)
{
$UserRole = Get-SCUserRole "MyUserRole"
$VM | Set-VM -Owner "DOMAIN\Owner" -UserRole $UserRole
} |
$VMs = Get-VM | Where Name -like "*CALL*" | Where UserRole -eq $Null
foreach ($VM in $VMs)
{
$UserRole = Get-SCUserRole "MyUserRole"
$VM | Set-VM -Owner "DOMAIN\Owner" -UserRole $UserRole
}
That will only change “null” user roles. If you want to change existing user roles:
1
2
3
4
5
6
| $VMs = Get-VM | Where Name -like "*CALL*" | Where UserRole -like "OldUserRole"
foreach ($VM in $VMs)
{
$UserRole = Get-SCUserRole "NewUserRole"
$VM | Set-VM -Owner "DOMAIN\Owner" -UserRole $UserRole
} |
$VMs = Get-VM | Where Name -like "*CALL*" | Where UserRole -like "OldUserRole"
foreach ($VM in $VMs)
{
$UserRole = Get-SCUserRole "NewUserRole"
$VM | Set-VM -Owner "DOMAIN\Owner" -UserRole $UserRole
}
It will only looks for VMs like “CALL”. You can leave it blank for all virtual machines.
Posted in Virtual Machine Manager, Windows Powershell | No Comment | 2,230 views | 26/07/2013 11:59
You can get total CPU and memory usage of a user role with following command:
1
| (Get-VM | Where UserRole -like "MyUserRole" | Measure-Object -Property CPUCount,Memory -Sum) |
(Get-VM | Where UserRole -like "MyUserRole" | Measure-Object -Property CPUCount,Memory -Sum)
That will give you total count of cpu and memory.
Posted in Windows Server | No Comment | 6,410 views | 19/07/2013 10:46
Bir sunucunun üzerine AD DC tarafından hangi GPO’ların basıldığını görmek istiyorsanız, aşağıdaki komutları kullanabilirsiniz.
rsop.msc
gpresult /h a.html
RSOP ile açılacak olan pencereden, basılmış olan GPO’lar rahatça görülebilmektedir.
Posted in Windows Powershell, Windows Server | No Comment | 1,764 views | 18/07/2013 10:10
You can get DNs of your servers with following PowerShell 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
| $DomainServers = Get-ADComputer -Filter *
$ChildDomainServers = Get-ADComputer -Filter * -SearchBase "DC=child,DC=domain,DC=com" -Server "child.domain.com"
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
$DN = $null;
$DN = ($DomainServers | where DNSHostName -eq "$Server").DistinguishedName
if (!$DN)
{
$DN = ($ChildDomainServers | where DNSHostName -eq "$Server").DistinguishedName
if (!$DN)
{
Add-Content -Value $Server -Path C:\DNs.txt
}
else
{
Add-Content -Value $DN -Path C:\DNs.txt
}
}
else
{
Add-Content -Value $DN -Path C:\DNs.txt
}
} |
$DomainServers = Get-ADComputer -Filter *
$ChildDomainServers = Get-ADComputer -Filter * -SearchBase "DC=child,DC=domain,DC=com" -Server "child.domain.com"
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
$DN = $null;
$DN = ($DomainServers | where DNSHostName -eq "$Server").DistinguishedName
if (!$DN)
{
$DN = ($ChildDomainServers | where DNSHostName -eq "$Server").DistinguishedName
if (!$DN)
{
Add-Content -Value $Server -Path C:\DNs.txt
}
else
{
Add-Content -Value $DN -Path C:\DNs.txt
}
}
else
{
Add-Content -Value $DN -Path C:\DNs.txt
}
}
You should add your server list into C:\Servers.txt.
Posted in Virtual Machine Manager, Windows Powershell, Windows Server | 1 Comment | 3,568 views | 16/07/2013 09:23
You can get Cluster names from your Hyper-V host list with following PowerShell 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
| # Prepare Cluster Array
$ClusterArray = New-Object System.Collections.ArrayList
$Servers = Get-Content -Path C:\Servers.txt
foreach ($Server in $Servers)
{
$VMHost = Get-VMHost -ComputerName $Server
$HyperVFQDN = $VMHost.FullyQualifiedDomainName
if ($VMHost)
{
$ClusterName = (@(Get-Cluster $Server | Get-ClusterGroup | where GroupType -eq "VirtualMachine") | Select-Object -First 1).Cluster.Name
if ($ClusterName)
{
$TestCluster = $ClusterArray.Contains("$ClusterName")
if ($TestCluster -ne $True)
{
# Update Cluster Array
$ClusterArray.Add("$ClusterName") | Out-Null
}
Write-Host $ClusterName
}
}
} |
# Prepare Cluster Array
$ClusterArray = New-Object System.Collections.ArrayList
$Servers = Get-Content -Path C:\Servers.txt
foreach ($Server in $Servers)
{
$VMHost = Get-VMHost -ComputerName $Server
$HyperVFQDN = $VMHost.FullyQualifiedDomainName
if ($VMHost)
{
$ClusterName = (@(Get-Cluster $Server | Get-ClusterGroup | where GroupType -eq "VirtualMachine") | Select-Object -First 1).Cluster.Name
if ($ClusterName)
{
$TestCluster = $ClusterArray.Contains("$ClusterName")
if ($TestCluster -ne $True)
{
# Update Cluster Array
$ClusterArray.Add("$ClusterName") | Out-Null
}
Write-Host $ClusterName
}
}
}
After that you can use your Cluster names to get CSV reports.
|