Thursday, September 23, 2010

Reset Administrator password from HP Virtual Connect and Onbord Administrator

If you have some guys which makes fun to change password on a virtual connect there is a procedure to reset administrator password to it original setting.

This procedure comes from c00865618.pdf file page 28 HP Virtual Connect for c-Class BladeSystem User Guide

Resetting the Administrator password and DNS settings
-----------------------------------------------------
If the system maintenance switch 1 is in the ON position on a VC-Enet module, the firmware restores the Administrator account password and DNS settings to the original factory defaults as found on the module label (without disturbing any other local user accounts), and also displays the password on the VC-Enet module management console. For information on accessing the VC-Enet module management console, see the OA user guide. The default password is no longer displayed after switch 1 is in the OFF position.

Password restoration is done during each power-up sequence while switch 1 is in the ON position (and reserved switches are in the OFF position) and does not allow changes until the switch is placed back into the OFF position. For switch locations, see the appropriate system maintenance switch ("HP 1/10Gb VCEnet Module system maintenance switch" on page 15, "HP 1/10Gb-F VC-Enet Module system maintenance switch" on page 18, "HP Virtual Connect Flex-10 10Gb Ethernet Module system maintenance switch" on page 22).
After switch 1 is returned to the OFF position, users with appropriate privileges can then change the Administrator password.
Only reset the password on the module running the Virtual Connect Manager (and/or its backup), and not other modules in the domain.



The recommended password recovery procedure is as follows:

1. Remove the Virtual Connect Ethernet module from interconnect bay 1.

2. Remove the access panel from the Virtual Connect Ethernet module.

3. Set switch 1 to the ON position. Ensure that all other switches remain in the OFF position.

4. Install the access panel.

5. Insert the Virtual Connect Ethernet module into bay 1 and allow the module to power up and reach a fully booted and operational state (approximately 1 minute).

6. Remove the Virtual Connect Ethernet module from interconnect bay 2.
This causes interconnect bay 1 to become the module running the active VC Manager. Because switch 1 is set, the Administrator password remains at the factory default for interconnect bay 1 (not overwritten by the change of state because of the failover).

7. Wait to ensure that the VC Manager has had time to become active on interconnect bay 1. Log into the VC Manager to confirm it is up and functional on interconnect bay 1.

8. Insert the Virtual Connect Ethernet module into interconnect bay 2 and allow the module to power on and reach a fully booted and operational state (approximately 1 minute).

9. Remove the Virtual Connect Ethernet module from interconnect bay 1.

10. Remove the access panel from the Virtual Connect Ethernet module.

11. Set switch 1 to the OFF position. Ensure that all other switches remain in the OFF position.

12. Install the access panel.

13. Insert the Virtual Connect Ethernet module into interconnect bay 1 and allow the module to power up and reach a fully booted and operation state (approximately 1 minute).

14. Log into the VC Manager using the factory default user name and password to log in to the module (regardless of whether it is running on the module







[EDIT MARCH 12 2012] FOR ONBOARD ADMINISTRATOR

FOR OA this link http://h30499.www3.hp.com/t5/HP-BladeSystem-Management/Resetting-the-Onboard-Administrator-password/td-p/2304569 explain how to do on OA
I re-copy it for everyone:


Brian had an Onboard Administrator question:
**********************
I have two chassis were the customer has lost the passwords. They are not set to the default. Does anyone have password recovery procedures. Downtime and configuration is not any concern as this is a new install.
**********************
Bill had the process down:
********************
From the OA 3.10 user Guide, page 19...

Recovering the administrator password

If the administrator password has been lost, you can reset the administrator password to the factory default that shipped on the tag with the Onboard Administrator module. The Onboard Administrator resets a lost password to Lost Password/Flash Disaster Recovery (LP/FDR) mode. To recover the password and reset the administrator password to the factory default:

1. Connect a computer to the serial port of the Active Onboard Administrator using a null-modem cable.

2. With a null-modem cable (9600 N, 8, 1, VT100, locally connect to the Onboard Administrator).

3. Open HyperTerminal (in Microsoft(r) Windows(r)) or a suitable terminal window (in Linux), and then connect to the Active Onboard Administrator.

4. Press and hold in the Onboard Administrator reset button for 5 seconds.

5. To boot the system into Lost Password modem Press L. The password appears as the system reboots.

************************
from Ken:

*********************

I prefer to use a script on a thumb drive to recover lost OA passwords. I’ve attached 2 scripts. ResetPW resets the “Administrator” account password to “password”. The OA-Add-admin script adds use “admin” password “hpinvent” to the OA, and all ILOs in the enclosure.

To run the scripts:

Copy the scripts to a thumb drive
Place the thumb drive in the active OA
Run the script from the Insight Display

o USB Menu
o Restore Configuration
o usb://d1/script-name.cfg

Script 1:
ADD USER admin hpinvent
SET USER ACCESS admin ADMINISTRATOR
ASSIGN SERVER ALL admin
ASSIGN INTERCONNECT ALL admin
ASSIGN OA admin
ENABLE USER admin
HPONCFG all << end_marker
<RIBCL VERSION="2.0">
<LOGIN USER_LOGIN="adminname" PASSWORD="password">
<USER_INFO MODE="write">
<ADD_USER
USER_NAME="admin"
USER_LOGIN="admin"
PASSWORD="hpinvent">
<ADMIN_PRIV value ="Yes"/>
<REMOTE_CONS_PRIV value ="Yes"/>
<RESET_SERVER_PRIV value ="Yes"/>
<VIRTUAL_MEDIA_PRIV value ="Yes"/>
<CONFIG_ILO_PRIV value="Yes"/>
</ADD_USER>
</USER_INFO>
</LOGIN>
</RIBCL>
end_marker

Script 2:
SET USER PASSWORD "Administrator" "password"

Tuesday, September 21, 2010

Export SCCM informations to CSV and send it by FTP

A script that export by FTP some SCCM informations to re-use in a personal intranet.
(Download it). That script retrieve cpu, memory, OS, interfaces, disks informations using SQL server queries. To use it, modify next lines by yours.
$hashOptions["strServerInstance"] = "DBserver\DBInstance"
$hashOptions["strDatabase"] = "SMS_XXX"



#
#
# Export SCCM Infos
#
# by F.Richard 2010-09
#

set-psdebug -strict


# Script Directory
$strCurDir = Split-Path -parent $MyInvocation.MyCommand.Path
Set-Location $strCurDir | Out-Null
#Write-Host "Current Dir: $strCurDir"

#$debug = $True
$debug = $False


# ***********************************************



Function executeSQLQuery {
Param ([hashtable]$options)
$strServerInstance = $(if ($options.ContainsKey("strServerInstance")) {$options["strServerInstance"]} else {"(local)"}) # ex: srv\inst
$strConnectionName = $(if ($options.ContainsKey("strConnectionName")) {$options["strConnectionName"]} else {"connectionname"})
$strDatabase = $(if ($options.ContainsKey("strDatabase")) {$options["strDatabase"]} else {"default"})
$strCommandTimeout = $(if ($options.ContainsKey("strCommandTimeout")) {$options["strCommandTimeout"]} else {"15"})

$strUser = $(if ($options.ContainsKey("strUser")) {"User Id=" + $options['strUser'] + ";"} else {""})
$strPassword = $(if ($options.ContainsKey("strPassword")) {"Password=" + $options['strPassword'] + ";"} else {""})
$strAuthentication = $(if ($strUser -and $strPassword) {"$strUser$strPassword"} else {"Integrated Security=SSPI"})

$strQuery = $(if ($options.ContainsKey("strQuery")) {$options['strQuery']} else {""})


If ($debug) {
Write-Host "DEBUG: strServerInstance:" $strServerInstance
Write-Host "DEBUG: strConnectionName:" $strConnectionName
Write-Host "DEBUG: strDatabase:" $strDatabase
Write-Host "DEBUG: strCommandTimeout:" $strCommandTimeout
Write-Host "DEBUG: strUser:" $strUser
Write-Host "DEBUG: strPassword:" $strPassword
Write-Host "DEBUG: strAuthentication:" $strAuthentication
Write-Host "DEBUG: strQuery:" $strQuery
}

# Create SqlConnection
$conn = New-Object ('System.Data.SqlClient.SqlConnection')
If (!$conn) {
Write-Host "ERROR: Sql Connection could not be created!"
Exit
}

# http://www.connectionstrings.com/ for more details
# "Integrated Security=SSPI" = "Trusted_Connection=true" ->is telling SQL Server to use windows authentication -> User Id & Password not used
$connString = "Server=$strServerInstance;$strAuthentication;Database=$strDatabase;Application Name=$strConnectionName"
If ($debug) {
Write-Host "DEBUG: Sql Connection String:" $connString
}
$conn.ConnectionString = $connString
$dtResult = New-Object "System.Data.DataTable"
$conn.Open()
If ($conn.State -eq 1) {
$sqlCmd = New-Object "System.Data.SqlClient.SqlCommand"
If ($sqlCmd) {
$sqlCmd.CommandTimeout = $strCommandTimeout
$sqlCmd.CommandText = $strQuery
$sqlCmd.Connection = $conn

# INSERT, UPDATE or DELETE ExecuteNonQuery()
# SELECT ExecuteReader()
$data = $sqlCmd.ExecuteReader()
$dtResult.Load($data) # fill
$data.Dispose()
$sqlCmd.Dispose() # frees all resources that were used by the object.
} Else {
Write-Host "ERROR: Cannot create SqlCommand object!";
}
} Else {
Write-Host "ERROR: Connection cannot be opened!";
}
$conn.Close()
$conn = $Null

#$dtResult | Format-Table -autosize
return $dtResult
}


# ***********************************************

Function getServersList {

$yesterday = Get-Date((Get-Date).AddDays(-1)) -uformat "%d/%m/%Y"
If ($debug) { Write-Host "yesterday:" $yesterday }

$query = "SELECT DISTINCT system.[Name0] AS name_machine
,comp.[Model0] AS model
,system.SystemRole0 AS name_model
,comp.[Manufacturer0] AS constructor
,comp.[Domain0] AS domain
,MAX(system2.User_Name0) AS lastLoggedInUser
FROM [v_GS_SYSTEM] system
JOIN [v_R_System] system2 ON system2.ResourceID = system.ResourceID
JOIN [v_GS_COMPUTER_SYSTEM] comp ON comp.ResourceID = system.ResourceID
JOIN [v_Gs_Workstation_Status] WStatus ON WStatus.ResourceID = comp.ResourceID
WHERE 1=1
AND convert(VarChar(11), WStatus.LastHwScan, 103) = '$yesterday' -- 103 = dd/mm/yy but here = dd/mm/yyyy
GROUP BY system.[Name0], comp.[Model0], system.SystemRole0, comp.[Manufacturer0], comp.[Domain0]
ORDER BY name_machine"

$dtResult = New-Object "System.Data.DataTable"

$hashOptions = @{ }
$hashOptions["strServerInstance"] = "DBserver\DBInstance"
$hashOptions["strDatabase"] = "SMS_XXX"
#$hashOptions["strUser"] = "user"
#$hashOptions["strPassword"] = "password"
$hashOptions["strQuery"] = $query
$dtResult = executeSQLQuery($hashOptions)

If ($dtResult -ne $Null) {
New-Item ".\SCCM_Hardware.csv" -type file -force | out-null
Foreach ($row in $dtResult){
$query = "SELECT [SerialNumber0]
FROM V_GS_PC_BIOS bios
LEFT OUTER JOIN v_GS_SYSTEM system
ON bios.ResourceID = system.ResourceID
WHERE UPPER(system.Name0)='" + $row.name_machine.ToUpper() + "'"
$hashOptions["strQuery"] = $query
$dtResult2 = executeSQLQuery($hashOptions)
If ($dtResult2 -ne $Null) {
Foreach ($row2 in $dtResult2){
$result = $row.name_machine + ";" + $row.name_model + ";" + $row.constructor + ";" + $row.model + ";" + $row.domain + ";" + $row.lastLoggedInUser + ";" + $row2.SerialNumber0
$result | out-file -encoding OEM ".\SCCM_Hardware.csv" -append
}
}
}


# Memory
New-Item ".\SCCM_Memory.csv" -type file -force | out-null
Foreach ($row in $dtResult){
$query = "SELECT mem.[TotalPhysicalMemory0] AS totalphysicalmem -- 3407160
FROM v_GS_X86_PC_MEMORY mem
LEFT OUTER JOIN v_GS_SYSTEM system ON system.ResourceID = mem.ResourceID
WHERE UPPER(system.Name0)='" + $row.name_machine.ToUpper() + "'
AND mem.RevisionID = (
SELECT MAX(mem2.RevisionID) FROM v_GS_X86_PC_MEMORY mem2
LEFT OUTER JOIN v_GS_SYSTEM system2 ON system2.ResourceID = mem2.ResourceID
WHERE UPPER(system2.Name0)='" + $row.name_machine.ToUpper() + "')"
$hashOptions["strQuery"] = $query
$dtResult2 = executeSQLQuery($hashOptions)
If ($dtResult2 -ne $Null) {
Foreach ($row2 in $dtResult2){
$result = $row.name_machine + ";" + $row2.totalphysicalmem
$result | out-file -encoding OEM ".\SCCM_Memory.csv" -append
}
}
}


# CPU
New-Item ".\SCCM_CPU.csv" -type file -force | out-null
Foreach ($row in $dtResult){
$query = "SELECT process.nb_socket
,COUNT(DISTINCT processor.DeviceID0) AS number_core
,processor.[MaxClockSpeed0] AS frequency
,RTRIM(LTRIM(processor.Name0)) AS type_cpu
FROM [v_GS_PROCESSOR] processor

LEFT OUTER JOIN v_GS_SYSTEM system
ON processor.ResourceID = system.ResourceID

LEFT OUTER JOIN (SELECT p.ResourceID, COUNT(DISTINCT p.[SocketDesignation0]) AS nb_socket FROM [v_GS_PROCESSOR] p GROUP BY p.ResourceID)
process ON process.ResourceID = system.ResourceID

WHERE UPPER(system.Name0) = '" + $row.name_machine.ToUpper() + "'" + "
GROUP BY process.nb_socket
,processor.[MaxClockSpeed0]
,processor.Name0"

$hashOptions["strQuery"] = $query
$dtResult2 = executeSQLQuery($hashOptions)
If ($dtResult2 -ne $Null) {
Foreach ($row2 in $dtResult2){
$result = $row.name_machine + ";" + $row2.nb_socket + ";" + $row2.number_core + ";" + $row2.frequency + ";" + $row2.type_cpu
$result | out-file -encoding OEM ".\SCCM_CPU.csv" -append
}
}
}

# Interfaces
New-Item ".\SCCM_Interfaces.csv" -type file -force | out-null
Foreach ($row in $dtResult){
$query = "SELECT netadapt.[DefaultIPGateway0] AS gateway
,netadapt.[DHCPServer0] AS dhcp
,netadapt.[IPAddress0] AS ip
,netadapt.[IPSubnet0] AS mask
,netadapt.[MACAddress0] mac_interface
FROM v_GS_SYSTEM system
LEFT OUTER JOIN v_GS_NETWORK_ADAPTER_CONFIGUR netadapt ON
netadapt.ResourceID = system.ResourceID
WHERE UPPER(system.Name0)= '" + $row.name_machine.ToUpper() + "' AND
DefaultIPGateway0 IS NOT NULL"
$hashOptions["strQuery"] = $query
$dtResult2 = executeSQLQuery($hashOptions)
If ($dtResult2 -ne $Null) {
Foreach ($row2 in $dtResult2){
$result = $row.name_machine + ";" + $row2.gateway + ";" + $row2.dhcp + ";" + $row2.ip + ";" + $row2.mask + ";" + $row2.mac_interface
$result | out-file -encoding OEM ".\SCCM_Interfaces.csv" -append
}
}
}

# Os
New-Item ".\SCCM_OS.csv" -type file -force | out-null
Foreach ($row in $dtResult){
$query = "SELECT [Caption0] AS capsystem
,[CSDVersion0] AS patch
,[InstallDate0] AS date_install
,[LastBootUpTime0] AS lastbootuptime
,[Version0] AS version_os
FROM v_GS_OPERATING_SYSTEM os
LEFT OUTER JOIN v_GS_SYSTEM system ON system.ResourceID = os.ResourceID
WHERE UPPER(system.Name0) = '" + $row.name_machine.ToUpper() + "'"
$hashOptions["strQuery"] = $query
$dtResult2 = executeSQLQuery($hashOptions)
If ($dtResult2 -ne $Null) {
Foreach ($row2 in $dtResult2){
$result = $row.name_machine + ";" + $row2.capsystem + ";" + $row2.patch + ";" + $row2.date_install + ";" + $row2.lastbootuptime + ";" + $row2.version_os
$result | out-file -encoding OEM ".\SCCM_OS.csv" -append
}
}
}

# Disk
New-Item ".\SCCM_Disk.csv" -type file -force | out-null
Foreach ($row in $dtResult){
$query = "SELECT LTRIM(RTRIM([Description0])) AS id_type_disk -- local Fixed Disk or CD-ROM Disc
,[DeviceID0] AS letter -- D: or Z:
,[FileSystem0] AS id_file_system -- NTFS, FAT32, etc.
,[FreeSpace0] AS free_space
,system.[Name0] AS id_machine
,[Size0] AS size
,[VolumeName0] AS volume_name
,[VolumeSerialNumber0] AS volume_serial_number
FROM [v_GS_LOGICAL_DISK] logdisk
LEFT OUTER JOIN [v_GS_SYSTEM] system ON system.ResourceID = logdisk.ResourceID
WHERE UPPER(system.Name0) = '" + $row.name_machine.ToUpper() + "' AND [FileSystem0] IS NOT NULL"
$hashOptions["strQuery"] = $query
$dtResult2 = executeSQLQuery($hashOptions)
If ($dtResult2 -ne $Null) {
Foreach ($row2 in $dtResult2){
$result = $row.name_machine + ";" + $row2.id_type_disk + ";" + $row2.letter + ";" + $row2.id_file_system + ";" + $row2.free_space + ";" + $row2.id_machine + ";" + $row2.size + ";" + $row2.volume_name + ";" + $row2.volume_serial_number
$result | out-file -encoding OEM ".\SCCM_Disk.csv" -append
}
}
}
}

$dtResult = $Null

# FTP all .CSV
$today = Get-Date -uformat "%Y-%m-%d" # 2010-03-01
If (!(Test-Path "$strCurDir\log")) {
New-Item -Path "$strCurDir\log" -type directory | Out-Null
}
$ftp = "
open yourftpserver
ftpuser
ftppassword
mput `"$strCurDir\*.csv`"
quit
"
$ftp | out-file -encoding OEM ".\ftp-send.txt"

$cmdline = "ftp -i -s:`"" + $strCurDir + "\ftp-send.txt`" > `"" + $strCurDir + "\log\ftp_$today.txt`""
If ($debug) { Write-Host $cmdline }
cmd /c $cmdline
}

# ***********************************************

getServersList

Wednesday, September 1, 2010

Some tools interesting in Gilles Laurent's site

Gilles Laurent's site (http://glsft.free.fr/) is French site (sorry for english people), but some script or tools are interesting as these ones:

EmbedFileInVBScript
http://glsft.free.fr/index.php?option=com_content&task=view&id=38&Itemid=33
A vbscript which permit to transform binary to text (for exemple, can be used for RDP to export binary to a computer by clipboard, when you do not have rights to copy files directly)

DynSetEnv
http://glsft.free.fr/index.php?option=com_content&task=view&id=67&Itemid=28
A tool to create environment variable like SET in cmd but with parent process propogation

RunAsLoggedOnUser
http://glsft.free.fr/index.php?option=com_content&task=view&id=31&Itemid=28
A tool to execute a process with user right connected on computer

DynaWrap
http://glsft.free.fr/index.php?option=com_content&task=view&id=47&Itemid=33
An improved version of WSHDDynacall http://ourworld.compuserve.com/homepages/Guenter_born/WSHBazaar/WSHDynaCall.htm
permitting to call API in vbscript, perl...

Delete some local users and do a report

Today, support team need help to delete a lot of same local users on multiple servers which are in a workgroup (do not ask me why they do not use AD and domain....). And all these deletions must be report.
Like today I do not have really a lot of time to help them (too much projects to finish and manage today) I decided to do a 5 min batch script.

Here it is DeleteLocalUsers.cmd

set inputfile=users.txt
set result=result.txt
echo. >%result%
for /F %%i IN (%inputfile%) Do echo %%i >> %result% 2>>&1 & net user %%i /delete >> %result% 2>>&1


This batch use an input file named users.txt that containing users to delete like this:

aaaaaaa
bbbbbbb


No you just to run batch script to delete users (report file named result.txt)
Here user aaaaaa whas created before and bbbbbb does not exist

aaaaaa
The command completed successfully.

bbbbbb
The user name could not be found.

More help is available by typing NET HELPMSG 2221.


For better report, you can improve batch by testing if it's a successfull deletion by testing "successfully" with findstr command and errorlevel
If you need to execute this batch remotely on multiple computers, use psexec in for loop with a computers.txt file
(for example see in my blog in HP Onboard administrator and Citrix backup posts)

To download it