Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts
Thursday 18 January 2018
Thursday 27 October 2016
Citrix Studio - Change Hypervisor Connection
In Citrix Studio, it is possible to create a new hypervisor connection, and move the VMs to that new connection. The reason new connection be created and we move VMs to that connection can be varies – from commissioning new vCentre server to changing to a new hypervisor platform (from Microsoft Hyper-V to VMware vSphere).
This post will explain on how to change the connection from current to a new one. The connection needs to be already established prior to implementation of this steps.
- RDP to Citrix Studio server, and launch PowerShell. Add Citrix snap-in by following below command.
- Identify current and to be used Broker Connection IDs by using below command. In this example, I want to change from Hypervisor Connection UID 1 to Hypervisor Connection UID 3Command : get-BrokerHypervisorConnection
Monday 24 October 2016
PowerShell - To Perform DNS Resolution Check-Up
So this is my second PowerShell script created by me. The first one was so simple and I use it in my XenDesktop environment. This script on the other hand, is aprt of my initiative in performing Active Directory clean-up in my environment.
The task of the script is simple - check the IP address of a machine name, then check the hostname of that IP address.
- If the machine name (A host record) and the hostname (PTR record) is similar, we are good.
- If the machine name (A host record) and the hostname (PTR record) is different, error prompted
- If the machine name (A host record) is available but the hostname (no PTR record) is not, error prompted
- If the machine is not avaiable (no A host record), error prompted.
I use $PSScriptRoot so the location of the script is dynamic, it does not necessarily need to be put at a specific location.
This is only part 1. I wish to add more features so it could be better next time.
############################################################
#
# This script is created by Heiry Zulkifli, in order to check DNS resolutions for hostnames.
# www.datakraf.co.nz
#
#######################################################################
Function FunctChkIPAdd ($Machine)
{
Try
{
$arr = [System.Net.Dns]::GetHostAddresses($Machine) | findstr "IPAddressToString"
$SplitArr = $arr -split ': '
$IPAdd = $SplitArr[1]
$ErrorCode = 0
RETURN $ErrorCode, $IPAdd
} Catch {
$ErrorCode = 1
RETURN $ErrorCode, $IPAdd
}
}
Function FunctChkHostname ($IPAdd)
{
Try
{
$arr = [System.Net.Dns]::GetHostbyAddress($IPAdd) | findstr "{}"
$SplitArr = $arr -split ' '
$FQDN = $SplitArr[0]
$SplitArr2 = $FQDN.Split('.')
$Hostname = $SplitArr2[0]
$ErrorCode = 0
RETURN $ErrorCode, $Hostname
} Catch {
$ErrorCode = 2
RETURN $ErrorCode, $Hostname
}
}
$strFileName = "$PSScriptRoot\result.txt"
if (Test-path $strFileName) {remove-item $strFileName}
"MACHINENAME IP ADDRESS HOSTNAME STATUS" >$strFileName
write-host ("Script starts...")
write-host ("Performing Flush DNS...")
ipconfig /flushdns
write-host ("Flush DNS completed")
write-host (".")
write-host (".")
write-host (".")
forEach ($Machine in get-Content $PSScriptRoot\machines.txt)
{
write-host ("Checking $Machine")
$ResultIPAdd = FunctChkIPAdd ($Machine)
If ($ResultIPAdd[0] -eq 0)
{
$ResultHostName = FunctChkHostname ($ResultIPAdd[1])
$Result = $ResultHostName[0]
IF ($Result -eq 0)
{ $IPAdd = $ResultIPAdd[1]
$HostName = $ResultHostName[1]
IF ($Machine -eq $HostName)
{
$info = "$Machine $IPAdd $HostName | OK"
} ELSE {
$info = "$Machine $IPAdd $HostName---------------| ERROR - Maching Different With Hostname"
}
} ELSE {
$info = "$Machine $IPAdd -------------------------------------------| ERROR-HostName Not Found"
}
} ELSE {
$info = "$Machine ----------------------------------------------| ERROR-machine Name Not Found"
}
$info >> $strFileName
$hostname=""
write-host (".................................Completed")
}
write-host (".")
write-host (".")
write-host (".")
write-host ("Script completed. Please check result.txt")
When launches...
Example of result.txt :
Thursday 29 September 2016
Citrix Studio – Receive ‘Error Expanding Nodes’ Error While Adding VMs from PVS
While adding VMs created by Citrix Provisioning Services, you may receive this error :
Error : ‘Error expanding node’.
This issue occurred as the machine catalogue was initially created in PVS version 6.x. and current PVS version is higher than that. This is a well-known issue and a Citrix article is available here.
Get It Resolved :
Error : ‘Error expanding node’.
This issue occurred as the machine catalogue was initially created in PVS version 6.x. and current PVS version is higher than that. This is a well-known issue and a Citrix article is available here.
Get It Resolved :
Friday 11 September 2015
How To : StoreFront Factory Reset / Rejoin Citrix StoreFront to Server Group
In some situations, you may need to unjoin a StoreFront server from an existing server group, and join the server to a different server group. However, after you remove it, there is no option to add it back. You will see this screen at your StoreFront server.
So, what it The easiest way? Reinstall StoreFront!.
However, there is another cool way to do this, especially if you want to show off in front of your customers (no, I have never done this), or if you want to flaunt your expertise in front of your juniors (never done this as well).
StoreFront Factory Reset / Rejoin Citrix StoreFront to Server Group
How To Do :
Reference :
So, what it The easiest way? Reinstall StoreFront!.
However, there is another cool way to do this, especially if you want to show off in front of your customers (no, I have never done this), or if you want to flaunt your expertise in front of your juniors (never done this as well).
Description :
StoreFront Factory Reset / Rejoin Citrix StoreFront to Server Group
How To Do :
- Close all opened / active Storefront consoles. You will get error if there is active session. Launch PowerShell as Administrator.
- Type asnp Citrix*
- Browse to %Program Files%\Citrix\Receiver StoreFront\Scripts
- Run ImportModules.ps1
- Modules imported
- Run this command : Clear-DSConfiguration
- Command completed.
- Close PowerShell, and launch StoreFront. You will get the option to join to existing server group back.
Reference :
- http://support.citrix.com/article/CTX200239
Thursday 17 July 2014
Error on Powershell - 0xffff0000
I am not very familiar with PowerShell, yet... really. Currently, my main scripting language is VBScript. However, I am truly believe the needs to learn PowerShell is keep increasing every single day. Server 2008 and Server 2012 are equiped with PowerShell, some advanced managements in XenDesktop 7.5 are using PowerShell, it is fun to learn PowerShell (they said), and a few other points mentioned by my colleagues (Wow, what on earth Heiry, why your introduction is longer than an episode of Dads?)
Error encountered when a scheduled task created to run PowerShell script :
Furthermore, this error reported on Task Scheduler.
Troubleshooting
Resolution :
There are 2 methods to solve this :-
Method 01 - Using Registry Editor :
Method 02 - Using GUI :
Issues :
Error encountered when a scheduled task created to run PowerShell script :
The shell cannot be started. A failure occurred during initialization: Object reference not set to an instance of an object.
Furthermore, this error reported on Task Scheduler.
Troubleshooting
- Go to Start > Run, and type regedit. Press Enter
- Registry Editor launched. Browse to My Computer > HKEY_CURRENT_USER, and look for for Environment folder. It is not there.
- Next, go to My Computer > right click and choose Properties
- Go to Advanced tab, and click at Environment Variables...
- You won't see any entry on variable, as below :
There are 2 methods to solve this :-
Method 01 - Using Registry Editor :
- Launch REGEDIT. Browse to My Computer > right click at HKEY_CURRENT USER > hover at New > Choose Key
- Change the new Key name to Environment
- Now, lets refresh Registry Editor by pressing View > Refresh
- We can see the new key is arranged accordingly.
- Next, rignt click at Environment key > go to New > choose Expandable String Value
- Right click at newly created strign entry, and choose Rename and name it as TMP
- Right click at TMP string, and choose Modify
- Configure below string to Value data box :
String : %USERPROFILE%\Local Settings\Temp - Perform step 5 until 8 with below info :
String Name : TEMP
Value Data : %USERPROFILE%\Local Settings\Temp
Method 02 - Using GUI :
- Right Click at My Computer > choose Properties > click at Advanced Tab > Click at Environment Variables
- We will add the strings from here. Choose New
- Configure the variable names and variable values accordingly, then press OK
Variable name : TMP
Variable Value : %USERPROFILE%\Local Settings\Temp
Variable name : TEMP
Variable Value : %USERPROFILE%\Local Settings\Temp - This is the outcome. Press OK, and launch the PowerShell script to test.