|
Size: 10310
Comment:
|
← Revision 68 as of 2018-01-23 04:33:12 ⇥
Size: 14015
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 123: | Line 123: |
| == Physical disk info == wmic diskdrive list brief * Or with PowerShell: Get-WmiObject Win32_DiskDrive {{{ PS C:\Users\Administrator\Desktop> Get-ExecutionPolicy Restricted PS C:\Users\Administrator\Desktop> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned PS C:\Users\Administrator\Desktop> Get-ExecutionPolicy RemoteSigned }}} {{{ $Username = 'administrator' $Password = 'Vista@dadi' $pass = ConvertTo-SecureString -AsPlainText $Password -Force $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass Invoke-Command -credential $Cred -ComputerName 172.30.55.190 -ScriptBlock { wmic diskdrive list brief } }}} Caption DeviceID Model Partitions Size DELL PERC H730 Mini SCSI Disk Device \\.\PHYSICALDRIVE0 DELL PERC H730 Mini SCSI Disk Device 3 898315729920 == wmic memorychip get == == wmic baseboard get serialnumber == == Windows powershell all == http://ipmiutil.sourceforge.net/ === Copy file to remote host === |
== PS C:\Windows\system32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned == {{{ 执行策略更改 执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 http://go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略? [Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): a }}} {{{ PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHosts -value 192.168.*.190 PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHosts -value * WinRM 安全配置。 此命令修改 WinRM 客户端的 TrustedHosts 列表。TrustedHosts 列表中的计算机可能不会经过身份验证。该客户端可能会向这些计算机发送凭据信息。是否确实要修改此列表? [Y] 是(Y) [N] 否(N) [S] 暂停(S) [?] 帮助 (默认值为“Y”): PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHosts -value 192.168.9.190 }}} == Cache credential to host == {{{ net use \\172.31.56.190\VistaInstall\PATCHES Vista@dadi /USER:administrator awk '{ print "net use \\\\"$1"\\VistaInstall\\PATCHES Vista@dadi /USER:administrator" }' all_windows_ip > all_windows_credential }}} == Copy file to remote host == |
| Line 176: | Line 167: |
== Physical disk info == wmic diskdrive list brief * Or with PowerShell: Get-WmiObject Win32_DiskDrive {{{ PS C:\Users\Administrator\Desktop> Get-ExecutionPolicy Restricted PS C:\Users\Administrator\Desktop> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned PS C:\Users\Administrator\Desktop> Get-ExecutionPolicy RemoteSigned }}} {{{ $Username = 'administrator' $Password = 'Vista@dadi' $pass = ConvertTo-SecureString -AsPlainText $Password -Force $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass Invoke-Command -credential $Cred -ComputerName 172.30.55.190 -ScriptBlock { wmic diskdrive list brief } }}} Caption DeviceID Model Partitions Size DELL PERC H730 Mini SCSI Disk Device \\.\PHYSICALDRIVE0 DELL PERC H730 Mini SCSI Disk Device 3 898315729920 == wmic memorychip get == == wmic baseboard get serialnumber == == Windows powershell all == http://ipmiutil.sourceforge.net/ |
|
| Line 238: | Line 264: |
== install patches == * https://technet.microsoft.com/en-us/library/security/ms17-010.aspx * https://4sysops.com/archives/use-powershell-invoke-command-to-run-scripts-on-remote-computers/ * https://harshilsharma63.wordpress.com/2014/12/27/how-to-install-multiple-msu-windows-update-files-with-powershell-script/ * http://techthoughts.info/remotely-install-windows-updates/ C:\Users\Administrator\Desktop\PSTools\PsExec64.exe \\127.0.0.1 -u administrator -p cisco,123 wusa c:\patches\windows6.1-kb4012212-x64_2decefaa02e2058dcd965702509a992d8c4e92b3.msu /quiet /norestart === mkdir c:\patches folder === {{{ $Username = 'administrator' $Password = 'Vista@dadi' $pass = ConvertTo-SecureString -AsPlainText $Password -Force $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass $servers = gc "C:\scripts\servers.txt" #param( #[string]$servers #) Invoke-Command -credential $Cred -ComputerName $servers -ScriptBlock { $setupFolder = "d:\VistaInstall\PATCHES" Write-Host "Creating SetupSoftwareAndFiles Folder" New-Item -Path $setupFolder -type directory -Force Write-Host "Folder creation complete" } }}} === copy install.ps to Windows c:\patches === {{{ $dir = (Get-Item -Path ".\" -Verbose).FullName Foreach($item in (ls $dir *.msu -Name)) { echo $item $item = $dir + "\" + $item wusa $item /quiet /norestart | Out-Null } }}} {{{ $Username = 'administrator' $Password = 'Vista@dadi' $pass = ConvertTo-SecureString -AsPlainText $Password -Force $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass # This file contains the list of servers you want to copy files/folders to $computers = gc "C:\scripts\servers.txt" # This is the file/folder(s) you want to copy to the servers in the $computer variable $source = "c:\patches\" #$source = "c:\scripts\install.ps1" # The destination location you want the file/folder(s) to be copied to $destination = "VistaInstall\PATCHES" foreach ($computer in $computers) { if ((Test-Path -Path \\$computer\$destination)) { #Copy-Item $source -Destination \\$computer\$destination -Recurs Copy-Item $source -Destination \\$computer\$destination -Recurs } else { "\\$computer\$destination is not reachable or does not exist" } } }}} |
@@ Syntax: 1.5 @@ Message: Other users will be warned until 2017-01-11 17:22:42 that @ you are editing this page. @@ Comment: None @@ Trivial: (x) Yes ( ) No Describe 首頁/2017-01-10 here.
Contents
大地影院硬件信息收集
root 123456 root ROOT@DADIMEDIA@!))))$ root ^2Front9011) root ^10Server9011)
Linux
ipmitool fru print
# rhel6 x64 # ansible 172.30.62.2 -m copy -a 'src=/mnt/play/systec/Projects/Dadi_Media大地影院/rhel6/megacli-8.07.14-1.x86_64.rpm dest=/tmp' ansible 172.30.62.2 -m copy -a 'src=/mnt/play/systec/Projects/Dadi_Media大地影院/rhel6/ipmitool-1.8.12-17.1.x86_64.rpm dest=/tmp' ansible 2x,7x,8x -m copy -a 'src=/mnt/play/systec/Projects/Dadi_Media大地影院/MegaCli-8.07.07-1.noarch.rpm dest=/tmp' ansible 172.30.62.2 -m raw -a 'rpm -Uvh /tmp/ipmitool*.rpm' ansible 2x,7x,8x -m raw -a 'rpm -Uvh /tmp/MegaCli*.rpm' # rhel5 i386 ansible 172.30.62.2 -m copy -a 'src=/mnt/play/systec/Projects/Dadi_Media大地影院/rhel5/ipmitool-1.8.11-99.dell.21.3.el5.i386.rpm dest=/tmp' ansible 172.30.62.2 -m copy -a 'src=/mnt/play/systec/Projects/Dadi_Media大地影院/rhel5/ipmitool-1.8.12-17.1.i386.rpm dest=/tmp' ansible 172.30.62.2 -m raw -a 'rpm -Uvh /tmp/ipmitool*.rpm'
ansible IPMI_x64 -m copy -a 'src=/mnt/play/Downloads/ipmitool-1.8.12-17.1.x86_64.rpm dest=/tmp' | tee /tmp/ipmi_copy ansible IPMI_x64 -m raw -a 'rpm -Uvh /tmp/ipmitool*.rpm' | tee /tmp/ipmi.8.install if [ ! -f /etc/init.d/ipmi ]; then ansible X.X.X.2,X.X.X.7,X.X.X.8 -m raw -a '/etc/init.d/ipmi start' | tee ipmi_start.log # ansible X.X.X.2,X.X.X.7,X.X.X.8 -m raw -a 'modprobe ipmi_devintf; ipmitool lan print | grep "IP Address ";ipmitool fru print ' | tee all_fru.log else ansible X.X.X.2,X.X.X.7,X.X.X.8 -m raw -a 'modprobe ipmi_devintf; ipmitool fru print ' | tee all_fru.log fi
Show Server Vendor&type
grep --after-context=3 'Builtin FRU Device' 8.all_linux_fru.log | grep "Board Product"
show all info
v1
ansible 2x,7x,7x -m raw -a 'modprobe ipmi_devintf; ipmitool fru print 2>/dev/null | egrep --after-context=6 'Builtin FRU Device|PS1|BP1|PERC' | megacli -PDList -a0 | egrep "Inquiry Data:|Raw Size:|PD Type:|Link Speed:"; smartctl -i -d megaraid,0 /dev/sda; dmidecode --type memory | head -38 | egrep "System Mem|Size:|Type:|Speed:|Part Number:";' | tee all_fru.log
v2
ansible 2x,7x,8x -m raw -a 'modprobe ipmi_devintf; ipmitool fru print 2>/dev/null | egrep --after-context=6 "Builtin FRU Device|PS.*ID|BP.*ID|PERC.*ID|Storage.*ID"; echo "----- The following Physical Disk Info is Generated by MegaCli -----"; /opt/MegaRAID/MegaCli/MegaCli* -PDList -a0 | egrep "Inquiry Data:|Raw Size:|PD Type:|Link Speed:"; echo " "; echo "----- The following Physical Disk Info is Generated by smartctl -----"; smartctl -i /dev/sg0; smartctl -i -d megaraid,0 /dev/sda; dmidecode --type memory | head -38 | egrep "System Mem|Size:|Type:|Speed:|Part Number:";' | tee all_fru_7x24x4.log
v3
ansible 2x,7x,8x -m raw -a 'modprobe ipmi_devintf; ipmitool fru print 2>/dev/null | egrep --after-context=6 "Builtin FRU Device|PS.*1|BP.*ID|PERC.*ID|Storage.*ID"; echo "-- The following Physical Disk Info is Generated by MegaCli --"; /opt/MegaRAID/MegaCli/MegaCli* -PDList -a0 | egrep "Inquiry Data:|Raw Size:|PD Type:|Link Speed:"; echo " "; echo "-- The following Physical Disk Info is Generated by smartctl --"; smartctl -i /dev/sg0| egrep --invert-match "smart|Copyrig"; smartctl -i -d megaraid,0 /dev/sda | egrep --invert-match "smart|Copyrig" | egrep "Vendor:|Product:|Revision:|User Capacity:|Serial number:|Device type:|Transport protocol:"; echo " "; echo "-- Memory FRU infomation by dmidecode -- "; dmidecode --type memory | head -38 | egrep "Size:|Type:|Speed:|Part Number:"; echo " "; echo "================================= BREACK HERE ================================="'| tee /tmp/test
grep "Builtin FRU Device" --after-context=6 --before-context=1 7x24x4.all_linux_fru_v2.txt
dmidecode
memory info
dmidecode --type memory | head -30 | egrep 'Size:|Type:|Speed:|Part Number:' dmidecode --type memory | head -38 | egrep "System Mem|Size:|Type:|Speed:|Part Number:" ansible 172.31.221.7 -m raw -a "dmidecode --type memory | head -30 | egrep 'Size:|Type:|Speed:|Part Number:'"
disk info
megaraid about
http://hwraid.le-vert.net/wiki/LSIMegaRAIDSAS
MegaCli download
https://www.broadcom.com/broadcom-search?q=megacli
"C:\Program Files\MegaCli_Windows\MegaCli64" -PDlist -a0
lspci -knn | grep 'RAID bus controller'
smartctl -i -d megaraid,0 /dev/sda
password not correct
172.31.240.8 192.168.69.7 172.30.16.7 172.30.46.7 172.30.47.7 172.30.55.7 172.30.57.7
brightmoon ~ # grep --before-context=2 Au X.X.X.8
172.31.240.8 | UNREACHABLE! => {
"changed": false,
"msg": "Authentication failure.",
brightmoon ~ # grep --before-context=2 "Authentication failure" X.X.X.8 | grep UNRE | awk '{ print $1,"ansible_ssh_pass=ROOT@DADIMEDIA@!))))$ ansible_ssh_user=root" }' >> /etc/ansible/hosts
"module_stderr": "Shared connection to 172.31.29.2 closed.\r\n"
--> missing python-simplejson module
--> 32bit Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Linux AHliuanServer-3 2.6.18-194.el5PAE #1 SMP Tue Mar 16 22:00:21 EDT 2010 i686 i686 i386 GNU/Linux 32bit Not supported
Windows
PS C:\Windows\system32> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
执行策略更改 执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 http://go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略? [Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): a
PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHosts -value 192.168.*.190 PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHosts -value * WinRM 安全配置。 此命令修改 WinRM 客户端的 TrustedHosts 列表。TrustedHosts 列表中的计算机可能不会经过身份验证。该客户端可能会向这些计算机发送凭据信息。是否确实要修改此列表? [Y] 是(Y) [N] 否(N) [S] 暂停(S) [?] 帮助 (默认值为“Y”): PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHosts -value 192.168.9.190
Cache credential to host
net use \\172.31.56.190\VistaInstall\PATCHES Vista@dadi /USER:administrator
awk '{ print "net use \\\\"$1"\\VistaInstall\\PATCHES Vista@dadi /USER:administrator" }' all_windows_ip > all_windows_credential
Copy file to remote host
http://www.vsysad.com/2016/06/powershell-script-to-copy-file-to-multiple-remote-servers/
# This file contains the list of servers you want to copy files/folders to
$computers = gc "C:\scripts\servers.txt"
# This is the file/folder(s) you want to copy to the servers in the $computer variable
$source = "C:\Software\EMC\Networker\NWVSS.exe"
# The destination location you want the file/folder(s) to be copied to
$destination = "C$\temp\"
#The command below pulls all the variables above and performs the file copy
foreach ($computer in $computers) {Copy-Item $source -Destination "\\$computer\$destination" -Recurse}Copy-Item -Path \\serverb\c$\programs\temp\test.txt -Destination \\$servers\c$\programs\test.txt;
Physical disk info
wmic diskdrive list brief
Or with PowerShell:
PS C:\Users\Administrator\Desktop> Get-ExecutionPolicy Restricted PS C:\Users\Administrator\Desktop> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned PS C:\Users\Administrator\Desktop> Get-ExecutionPolicy RemoteSigned
$Username = 'administrator'
$Password = 'Vista@dadi'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Invoke-Command -credential $Cred -ComputerName 172.30.55.190 -ScriptBlock { wmic diskdrive list brief }Caption DeviceID Model Partitions Size
DELL PERC H730 Mini SCSI Disk Device \\.\PHYSICALDRIVE0 DELL PERC H730 Mini SCSI Disk Device 3 898315729920
wmic memorychip get
wmic baseboard get serialnumber
Windows powershell all
http://ipmiutil.sourceforge.net/
Delete remote host file
Invoke-Command -ComputerName "othermachine" -ScriptBlock {Remove-Item "C:\Windows\temp\*" -Force}
Collect system info script
awk '{ print "Invoke-Command -credential $Cred -filepath C:\scripts\Windows_info_collect_v1.1.ps1 -computername",$1,"| tee c:\\scripts\\"$1"-FRU-Info.log" }' 190.Alive_list.txt
v1.0
$servers = get-content C:\dadi_windows.txt
$Username = 'administrator'
$Password = 'Vista@dadi'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Invoke-Command -HideComputerName -credential $Cred -ComputerName $servers -ScriptBlock { gwmi Win32_NetworkAdapterConfiguration |
Where { $_.IPAddress } | # filter the objects where an address actually exists
Select -Expand IPAddress | # retrieve only the property *value*
Where { $_ -like '*.190' } ;
echo "-- System info --";
Get-WmiObject Win32_ComputerSystem | select Manufacturer, Model | FL ;
wmic baseboard get serialnumber;
Get-WmiObject Win32_Processor | select Name | FL;
Get-CimInstance Win32_OperatingSystem | Select-Object Caption, InstallDate, OSArchitecture, BuildNumber | FL ;
echo "-- MEMORY info --"
Get-WmiObject Win32_PhysicalMemory | select DeviceLocator,Capacity,PartNumber,SerialNumber,TotalWidth,Speed | FL ;
echo "-- DISK info --";
#Get-WmiObject Win32_DiskDrive | select Model, Size | FL ;
wmic diskdrive list brief;
echo "-- Power Supply and maybe more ... --"
echo " "
& "C:\Program Files\ipmiutil\ipmiutil.exe" fru print;
echo "============================ BREAK HERE =============================="; } | Out-File C:\7x24x4.all_windows_fru_v1.log
v1.1
C:\scripts\Windows_info_collect_v1.1.ps1
gwmi Win32_NetworkAdapterConfiguration |
Where { $_.IPAddress } | # filter the objects where an address actually exists
Select -Expand IPAddress | # retrieve only the property *value*
Where { $_ -like '*.190' } ;
echo "-- System info --";
Get-WmiObject Win32_ComputerSystem | select Manufacturer, Model ;
wmic baseboard get serialnumber;
Get-WmiObject Win32_Processor | select Name | FL;
Get-CimInstance Win32_OperatingSystem | Select-Object Caption, InstallDate, OSArchitecture, BuildNumber | FL ;
echo "-- MEMORY info --"
Get-WmiObject Win32_PhysicalMemory | select DeviceLocator,Capacity,PartNumber,SerialNumber,TotalWidth,Speed | FL ;
echo "-- DISK info --";
#Get-WmiObject Win32_DiskDrive | select Model, Size | FL ;
wmic diskdrive list brief;
echo "-- Power Supply and Maybe MORE!!! ... --";
echo " ";
# & "ipconfig" | findstr /I 'ipv4';
& "C:\Program Files\ipmiutil\ipmiutil.exe" fru print;
install patches
https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
https://4sysops.com/archives/use-powershell-invoke-command-to-run-scripts-on-remote-computers/
C:\Users\Administrator\Desktop\PSTools\PsExec64.exe \\127.0.0.1 -u administrator -p cisco,123 wusa c:\patches\windows6.1-kb4012212-x64_2decefaa02e2058dcd965702509a992d8c4e92b3.msu /quiet /norestart
mkdir c:\patches folder
$Username = 'administrator'
$Password = 'Vista@dadi'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
$servers = gc "C:\scripts\servers.txt"
#param(
#[string]$servers
#)
Invoke-Command -credential $Cred -ComputerName $servers -ScriptBlock {
$setupFolder = "d:\VistaInstall\PATCHES"
Write-Host "Creating SetupSoftwareAndFiles Folder"
New-Item -Path $setupFolder -type directory -Force
Write-Host "Folder creation complete" }
copy install.ps to Windows c:\patches
$dir = (Get-Item -Path ".\" -Verbose).FullName
Foreach($item in (ls $dir *.msu -Name))
{
echo $item
$item = $dir + "\" + $item
wusa $item /quiet /norestart | Out-Null
}$Username = 'administrator'
$Password = 'Vista@dadi'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
# This file contains the list of servers you want to copy files/folders to
$computers = gc "C:\scripts\servers.txt"
# This is the file/folder(s) you want to copy to the servers in the $computer variable
$source = "c:\patches\"
#$source = "c:\scripts\install.ps1"
# The destination location you want the file/folder(s) to be copied to
$destination = "VistaInstall\PATCHES"
foreach ($computer in $computers) {
if ((Test-Path -Path \\$computer\$destination)) {
#Copy-Item $source -Destination \\$computer\$destination -Recurs
Copy-Item $source -Destination \\$computer\$destination -Recurs
} else {
"\\$computer\$destination is not reachable or does not exist"
}
}