lework 4 years ago
parent
commit
084272675e
  1. 26
      bat/vmware-batch.bat
  2. 16523
      powershell/exchange/ADDS_Inventory_V2.ps1
  3. 1454
      powershell/exchange/Get-ExchangeEnvironmentReport.ps1
  4. 4086
      powershell/exchange/Get-ExchangeTracking.ps1
  5. 5839
      powershell/exchange/HealthChecker.ps1
  6. 507
      powershell/exchange/MessageTrackingLogGUI.ps1
  7. 252
      powershell/exchange/Set-Webserver.ps1
  8. 31
      powershell/exchange/enable-ad-user-mailbox.ps1
  9. 176
      shell/get_proc_mem.sh
  10. 2
      shell/k8s/k8s-app-info.sh

26
bat/vmware-batch.bat

@ -1,6 +1,7 @@
@echo off @echo off
Setlocal enabledelayedexpansion Setlocal enabledelayedexpansion
::CODER BY lework ::CODER BY lework
:: 虚拟机需安装vmtool
title VMware Workstation 虚拟机批量管理 title VMware Workstation 虚拟机批量管理
@ -14,13 +15,13 @@ IF EXIST "%PROGRAMFILES(X86)%\VMware\VMware VIX\vmrun.exe" SET VMRUN=%PROGRAMFIL
:: 虚拟机存放目录 :: 虚拟机存放目录
set VMpath="D:\Virtual Machines" set VMpath="D:\Virtual Machines"
:: 虚拟机名称 :: 虚拟机名称
set VMname=CentOS_7.8_x64_node set VMname=Debian_10.2_x64_node
:: 虚拟机快照名称 :: 虚拟机快照名称
set VMSnapshot=init set VMSnapshot=init
:: 新建虚拟机数目 :: 新建虚拟机数目
set VMcount=5 set VMcount=5
:: 虚拟机owa模板位置 :: 虚拟机owa模板位置
set VMowa="D:\vmware owa\CentOS_7.8_x64_base.ova" set VMowa="D:\vmware owa\Debian_10.2_x64_base.ova"
:: 模板系统用户名 :: 模板系统用户名
set VMuser=root set VMuser=root
:: 模板系统密码 :: 模板系统密码
@ -28,7 +29,7 @@ set VMpass=123456
:: 虚拟机网络 :: 虚拟机网络
set VMnetwork=192.168.77 set VMnetwork=192.168.77
:: 虚拟机ip开始地址 :: 虚拟机ip开始地址
set VMipStart=130 set VMipStart=180
@ -52,6 +53,7 @@ echo.
echo. 输入 10 挂起虚拟机 echo. 输入 10 挂起虚拟机
echo. 输入 11 暂停虚拟机 echo. 输入 11 暂停虚拟机
echo. 输入 12 恢复虚拟机 echo. 输入 12 恢复虚拟机
echo. 输入 13 删除快照
echo. 输入 q 退出 echo. 输入 q 退出
echo. echo.
echo ============================== echo ==============================
@ -76,6 +78,7 @@ if "%input%"=="9" goto delete
if "%input%"=="10" goto suspend if "%input%"=="10" goto suspend
if "%input%"=="11" goto pausevm if "%input%"=="11" goto pausevm
if "%input%"=="12" goto unpausevm if "%input%"=="12" goto unpausevm
if "%input%"=="13" goto delsnapshot
:wait :wait
echo. echo.
@ -132,7 +135,7 @@ set name=!VMname!%%a
set /a num=%VMipStart%+%%a-1 set /a num=%VMipStart%+%%a-1
set ip=!VMnetwork!.!num! set ip=!VMnetwork!.!num!
echo !name!:!ip! echo !name!:!ip!
vmrun -T ws -gu !VMuser! -gp !VMpass! runProgramInGuest !VMpath!\!name!\!name!.vmx /bin/bash -c "sudo echo 'node!num!' > /etc/hostname; sudo sed -i 's/IPADDR=.*$/IPADDR="!ip!"/g' /etc/sysconfig/network-scripts/ifcfg-e*;/etc/init.d/network restart || sudo sed -i 's/address .*$/address !ip!/g' /etc/network/interfaces;/etc/init.d/network restart" nogui vmrun -T ws -gu !VMuser! -gp !VMpass! runProgramInGuest !VMpath!\!name!\!name!.vmx -noWait /bin/bash -c "echo 'node!num!' > /etc/hostname && echo '127.0.0.1 node!num!' >> /etc/hosts; sudo sed -i 's/IPADDR=.*$/IPADDR="!ip!"/g' /etc/sysconfig/network-scripts/ifcfg-e* || sudo sed -i 's/address .*$/address !ip!/g' /etc/network/interfaces; init 6" nogui
) )
echo. echo.
@ -308,6 +311,19 @@ vmrun -T ws start !VMpath!\!VMname!%%a\!VMname!%%a.vmx nogui
) )
goto wait goto wait
:delsnapshot
echo [删除快照...]
set /p VMname=请输入虚拟机名称(默认:%VMname%):
set /p VMcount=请输入虚拟机数量(默认:%VMcount%):
set /p VMSnapshot=请输入快照名称(默认:%VMSnapshot%):
for /l %%a in (1,1,%VMcount%) do (
set name=!VMname!%%a
echo !name!
vmrun -T ws deleteSnapshot !VMpath!\!name!\!name!.vmx !VMSnapshot!
)
goto wait
:setip :setip
echo [设置ip地址...] echo [设置ip地址...]
@ -322,7 +338,7 @@ set name=!VMname!%%a
set /a num=%VMipStart%+%%a-1 set /a num=%VMipStart%+%%a-1
set ip=!VMnetwork!.!num! set ip=!VMnetwork!.!num!
echo !name!:!ip! echo !name!:!ip!
vmrun -T ws -gu !VMuser! -gp !VMpass! runProgramInGuest !VMpath!\!name!\!name!.vmx /bin/bash -c "sudo sed -i 's/IPADDR=.*$/IPADDR="!ip!"/g' /etc/sysconfig/network-scripts/ifcfg-e*;/etc/init.d/network restart || sudo sed -i 's/address .*$/address !ip!/g' /etc/network/interfaces;/etc/init.d/network restart" nogui vmrun -T ws -gu !VMuser! -gp !VMpass! runProgramInGuest !VMpath!\!name!\!name!.vmx -noWait /bin/bash -c "echo 'node!num!' > /etc/hostname && echo '127.0.0.1 node!num!' >> /etc/hosts; sudo sed -i 's/IPADDR=.*$/IPADDR="!ip!"/g' /etc/sysconfig/network-scripts/ifcfg-e* || sudo sed -i 's/address .*$/address !ip!/g' /etc/network/interfaces; init 6" nogui
) )
goto wait goto wait

16523
powershell/exchange/ADDS_Inventory_V2.ps1

File diff suppressed because it is too large Load Diff

1454
powershell/exchange/Get-ExchangeEnvironmentReport.ps1

File diff suppressed because it is too large Load Diff

4086
powershell/exchange/Get-ExchangeTracking.ps1

File diff suppressed because it is too large Load Diff

5839
powershell/exchange/HealthChecker.ps1

File diff suppressed because it is too large Load Diff

507
powershell/exchange/MessageTrackingLogGUI.ps1

@ -0,0 +1,507 @@
function GenerateForm {
###############################################################################################################
# Version History:
#
# 1.1 - 18/07/2012 : https://gallery.technet.microsoft.com/office/MessageTrackingLog-search-72a5dbc7
# 2.0 - 12/19/2015 : Nicolas PRIGENT - www.get-cmd.com
# New features : search by subject / send results by email / export results in csv file
# Existing feature corrected : search by event ID did not work. Global variable was not created.
# Code optimized
#
# Description:
# This script searches the MessageTrackingLog in your Organization.
# You have to enter valid From Addr or To Addr or the subject and select the date.
# You can also select a specific event ID. You can leave the blank entry to search the whole TrackingLog.
#
###############################################################################################################
#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
#endregion
#region Generated Form Objects
$formTrackLog = New-Object System.Windows.Forms.Form
$labEventID = New-Object System.Windows.Forms.Label
$comboBoxEventID = New-Object System.Windows.Forms.ComboBox
$labEndDate = New-Object System.Windows.Forms.Label
$labStartDate = New-Object System.Windows.Forms.Label
$labFrom = New-Object System.Windows.Forms.Label
$dgResults = New-Object System.Windows.Forms.DataGrid
$dateTimePickerEnd = New-Object System.Windows.Forms.DateTimePicker
$dateTimePickerStart = New-Object System.Windows.Forms.DateTimePicker
$txtBoxRecipients = New-Object System.Windows.Forms.TextBox
$txtBoxSenders = New-Object System.Windows.Forms.TextBox
$buttonGo = New-Object System.Windows.Forms.Button
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
$labTo = New-Object System.Windows.Forms.Label
$labSubject = New-Object System.Windows.Forms.Label
$txtBoxSubject = New-Object System.Windows.Forms.TextBox
$txtBoxMail = New-Object System.Windows.Forms.TextBox
$txtBoxCSV = New-Object System.Windows.Forms.TextBox
$chkBoxCSV = New-Object System.Windows.Forms.CheckBox
$chkBoxMail = New-Object System.Windows.Forms.CheckBox
$txtBoxFromMail = New-Object System.Windows.Forms.TextBox
$txtBoxToMail = New-Object System.Windows.Forms.TextBox
$txtBoxCSV = New-Object System.Windows.Forms.TextBox
#endregion Generated Form Objects
#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
Add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$processData=
{
#This section determine the date and puts it in a working format
$array = New-Object System.Collections.ArrayList
$date1 = get-Date -date $dateTimePickerStart.value -uformat "%m/%d/%Y 00:00:01"
$date3 = [System.DateTime]$date1
$date2 = get-Date -date $dateTimePickerEnd.value -uformat "%m/%d/%Y 23:59:59"
$date4 = [System.DateTime]$date2
$Sort = "TimeStamp"
if ($ChoiceEventID -eq "BADMAIL" -or $ChoiceEventID -eq "DEFER" -or $ChoiceEventID -eq "DELIVER" -or $ChoiceEventID -eq "SEND" -or $ChoiceEventID -eq "DSN" -or $ChoiceEventID -eq "FAIL" -or $ChoiceEventID -eq "POISONMESSAGE" -or $ChoiceEventID -eq "RECEIVE" -or $ChoiceEventID -eq "REDIRECT" -or $ChoiceEventID -eq "RESOLVE" -or $ChoiceEventID -eq "SUBMIT" -or $ChoiceEventID -eq "TRANSFER" -or $ChoiceEventID -eq "EXPAND")
{
$EventID = $ChoiceEventID
}
else
{
$EventID = ""
}
if ( $EventID -ne "")
{
if(($txtBoxRecipients.text -eq "") -and ($txtBoxSenders.text -eq "") -and ($txtBoxSubject.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -start $date3 -end $date4 -EventID $EventID -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif (($txtBoxRecipients.text -eq "") -and ($txtBoxSenders.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -MessageSubject $txtBoxSubject.text -EventID $EventID -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif (($txtBoxSubject.text -eq "") -and ($txtBoxSenders.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -Recipients $txtBoxRecipients.text -EventID $EventID -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif (($txtBoxSubject.text -eq "") -and ($txtBoxRecipients.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -Sender $txtBoxSenders.text -EventID $EventID -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif ($txtBoxRecipients.text -eq "")
{
$ausgabe = Get-MessageTrackingLog -Sender $txtBoxSenders.text -MessageSubject $txtBoxSubject.text -EventID $EventID -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif ($txtBoxSenders.text -eq "")
{
$ausgabe = Get-MessageTrackingLog -Recipients $txtBoxRecipients.text -MessageSubject $txtBoxSubject.text -EventID $EventID -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif ($txtBoxSubject.text -eq "")
{
$ausgabe = Get-MessageTrackingLog -Recipients $txtBoxRecipients.text -sender $txtBoxSenders.text -EventID $EventID -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
}
else
{
if(($txtBoxRecipients.text -eq "") -and ($txtBoxSenders.text -eq "") -and ($txtBoxSubject.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif (($txtBoxRecipients.text -eq "") -and ($txtBoxSenders.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -MessageSubject $txtBoxSubject.text -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif (($txtBoxSubject.text -eq "") -and ($txtBoxSenders.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -Recipients $txtBoxRecipients.text -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject,EventID, serverhostname | sort $sort
}
elseif (($txtBoxSubject.text -eq "") -and ($txtBoxRecipients.text -eq ""))
{
$ausgabe = Get-MessageTrackingLog -Sender $txtBoxSenders.text -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif ($txtBoxRecipients.text -eq "")
{
$ausgabe = Get-MessageTrackingLog -Sender $txtBoxSenders.text -MessageSubject $txtBoxSubject.text -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif ($txtBoxSenders.text -eq "")
{
$ausgabe = Get-MessageTrackingLog -Recipients $txtBoxRecipients.text -MessageSubject $txtBoxSubject.text -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
elseif ($txtBoxSubject.text -eq "")
{
$ausgabe = Get-MessageTrackingLog -Recipients $txtBoxRecipients.text -sender $txtBoxSenders.text -start $date3 -end $date4 -resultsize unlimited | Select-object Timestamp, sender, @{Name='Recipients';Expression={[string]::join(";", ($_.Recipients))}}, messagesubject, EventID, serverhostname | sort $sort
}
}
if ($ausgabe) {
$array.addrange($ausgabe)
$dgResults.datasource = $array
$array | export-csv "MessageTrackingGUI.log"
if ($chkBoxCSV.Checked)
{
$array | export-csv $txtBoxCSV.text
}
if ($chkBoxMail.Checked)
{
$Date = Get-Date
$SubjectDate = "Exchange Message Tracking " + $Date.Tostring('HH:mm-MM.dd.yyyy')
send-mailmessage -to $txtBoxToMail.text -from $txtBoxFromMail.text -subject $SubjectDate -body "Attached is the message tracking" -Attachments 'MessageTrackingGUI.log' -BodyAsHTML -SmtpServer $txtBoxMail.text
}
$formTrackLog.refresh()
} else {
write-host "No results found!" -ForegroundColor white -BackgroundColor Red
}
}
$handler_comboBoxEventID_SelectedIndexChanged=
{
# Get the Event ID when item is selected
$Global:ChoiceEventID = $comboBoxEventID.selectedItem.ToString()
}
$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
$formTrackLog.WindowState = $InitialFormWindowState
}
#----------------------------------------------
#region Generated Form Code
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 550
$System_Drawing_Size.Width = 1000
$formTrackLog.ClientSize = $System_Drawing_Size
$formTrackLog.DataBindings.DefaultDataSourceUpdateMode = 0
$formTrackLog.ForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)
$formTrackLog.Name = "formTrackLog"
$formTrackLog.Text = "Message Tracking Log GUI - By Nicolas PRIGENT [www.get-cmd.com]"
$formTrackLog.add_Load($handler_formTrackLog_Load)
$labEventID.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 570
$System_Drawing_Point.Y = 5
$labEventID.Location = $System_Drawing_Point
$labEventID.Name = "labEventID"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 60
$labEventID.Size = $System_Drawing_Size
$labEventID.TabIndex = 18
$labEventID.Text = "Event ID:"
$labEventID.add_Click($handler_labEventID_Click)
$formTrackLog.Controls.Add($labEventID)
$comboBoxEventID.DataBindings.DefaultDataSourceUpdateMode = 0
$comboBoxEventID.FormattingEnabled = $True
$comboBoxEventID.Items.Add("")|Out-Null
$comboBoxEventID.Items.Add("SEND")|Out-Null
$comboBoxEventID.Items.Add("DELIVER")|Out-Null
$comboBoxEventID.Items.Add("RECEIVE")|Out-Null
$comboBoxEventID.Items.Add("FAIL")|Out-Null
$comboBoxEventID.Items.Add("DSN")|Out-Null
$comboBoxEventID.Items.Add("RESOLVE")|Out-Null
$comboBoxEventID.Items.Add("EXPAND")|Out-Null
$comboBoxEventID.Items.Add("REDIRECT")|Out-Null
$comboBoxEventID.Items.Add("TRANSFER")|Out-Null
$comboBoxEventID.Items.Add("SUBMIT")|Out-Null
$comboBoxEventID.Items.Add("POISONMESSAGE")|Out-Null
$comboBoxEventID.Items.Add("DEFER")|Out-Null
$System_Drawing_PointComboEVentID = New-Object System.Drawing.Point
$System_Drawing_PointComboEVentID.X = 630
$System_Drawing_PointComboEVentID.Y = 3
$comboBoxEventID.Location = $System_Drawing_PointComboEVentID
$comboBoxEventID.Name = "comboBoxEventID"
$System_Drawing_SizeComboEVentID = New-Object System.Drawing.Size
$System_Drawing_SizeComboEVentID.Height = 21
$System_Drawing_SizeComboEVentID.Width = 121
$comboBoxEventID.Size = $System_Drawing_SizeComboEVentID
$comboBoxEventID.TabIndex = 17
$comboBoxEventID.add_SelectedIndexChanged($handler_comboBoxEventID_SelectedIndexChanged)
$formTrackLog.Controls.Add($comboBoxEventID)
$labEndDate.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 300
$System_Drawing_Point.Y = 33
$labEndDate.Location = $System_Drawing_Point
$labEndDate.Name = "labEndDate"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 54
$labEndDate.Size = $System_Drawing_Size
$labEndDate.TabIndex = 12
$labEndDate.Text = "End"
$formTrackLog.Controls.Add($labEndDate)
$labStartDate.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 300
$System_Drawing_Point.Y = 5
$labStartDate.Location = $System_Drawing_Point
$labStartDate.Name = "labStartDate"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 54
$labStartDate.Size = $System_Drawing_Size
$labStartDate.TabIndex = 11
$labStartDate.Text = "Start"
$labStartDate.add_Click($handler_labStartDate_Click)
$formTrackLog.Controls.Add($labStartDate)
$dgResults.AllowSorting = $true
$dgResults.Anchor = 15
$dgResults.DataBindings.DefaultDataSourceUpdateMode = 0
$dgResults.DataMember = ""
$dgResults.HeaderForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 9
$System_Drawing_Point.Y = 108
$dgResults.Location = $System_Drawing_Point
$dgResults.Name = "dgResults"
$dgResults.PreferredColumnWidth = 200
$dgResults.ReadOnly = $True
$dgResults.RowHeadersVisible = $false
$dgResults.RowHeaderWidth = 60
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 500
$System_Drawing_Size.Width = 990
$dgResults.Size = $System_Drawing_Size
$dgResults.TabIndex = 9
$dgResults.add_Navigate($handler_dgResults_Navigate)
$formTrackLog.Controls.Add($dgResults)
$dateTimePickerEnd.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 360
$System_Drawing_Point.Y = 33
$dateTimePickerEnd.Location = $System_Drawing_Point
$dateTimePickerEnd.Name = "dateTimePicker2"
$System_Drawing_SizeEnd = New-Object System.Drawing.Size
$System_Drawing_SizeEnd.Height = 20
$System_Drawing_SizeEnd.Width = 200
$dateTimePickerEnd.Size = $System_Drawing_SizeEnd
$dateTimePickerEnd.TabIndex = 8
$formTrackLog.Controls.Add($dateTimePickerEnd)
$dateTimePickerStart.CustomFormat = "MM/DD/YYYY 00:00:01"
$dateTimePickerStart.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 360
$System_Drawing_Point.Y = 3
$dateTimePickerStart.Location = $System_Drawing_Point
$dateTimePickerStart.Name = "dateTimePicker1"
$System_Drawing_SizeStart = New-Object System.Drawing.Size
$System_Drawing_SizeStart.Height = 20
$System_Drawing_SizeStart.Width = 200
$dateTimePickerStart.Size = $System_Drawing_SizeStart
$dateTimePickerStart.TabIndex = 7
$formTrackLog.Controls.Add($dateTimePickerStart)
$txtBoxRecipients.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 40
$System_Drawing_Point.Y = 30
$txtBoxRecipients.Location = $System_Drawing_Point
$txtBoxRecipients.Name = "txtBoxRecipients"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 250
$txtBoxRecipients.Size = $System_Drawing_Size
$txtBoxRecipients.TabIndex = 4
$txtBoxRecipients.Text = ""
$formTrackLog.Controls.Add($txtBoxRecipients)
$txtBoxSubject.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 65
$System_Drawing_Point.Y = 65
$txtBoxSubject.Location = $System_Drawing_Point
$txtBoxSubject.Name = "txtBoxSubject"
$System_Drawing_SizeSubject = New-Object System.Drawing.Size
$System_Drawing_SizeSubject.Height = 20
$System_Drawing_SizeSubject.Width = 495
$txtBoxSubject.Size = $System_Drawing_SizeSubject
$txtBoxSubject.TabIndex = 4
$txtBoxSubject.Text = ""
$formTrackLog.Controls.Add($txtBoxSubject)
$txtBoxSenders.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 40
$System_Drawing_Point.Y = 3
$txtBoxSenders.Location = $System_Drawing_Point
$txtBoxSenders.Name = "txtBoxSenders"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 250
$txtBoxSenders.Size = $System_Drawing_Size
$txtBoxSenders.TabIndex = 3
$txtBoxSenders.Text = ""
$formTrackLog.Controls.Add($txtBoxSenders)
$buttonGo.DataBindings.DefaultDataSourceUpdateMode = 0
$buttonGo.ForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 755
$System_Drawing_Point.Y = 3
$buttonGo.Location = $System_Drawing_Point
$buttonGo.Name = "button1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 25
$System_Drawing_Size.Width = 240
$buttonGo.Size = $System_Drawing_Size
$buttonGo.TabIndex = 1
$buttonGo.Text = ">>> Run <<<"
$buttonGo.UseVisualStyleBackColor = $True
$buttonGo.add_Click($processData)
$formTrackLog.Controls.Add($buttonGo)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 3
$System_Drawing_Point.Y = 5
$labFrom.Location = $System_Drawing_Point
$labFrom.Name = "labFrom"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 54
$labFrom.Size = $System_Drawing_Size
$labFrom.TabIndex = 11
$labFrom.Text = "From:"
$formTrackLog.Controls.Add($labFrom)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 3
$System_Drawing_Point.Y = 32
$labTo.Location = $System_Drawing_Point
$labTo.Name = "labTo"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 54
$labTo.Size = $System_Drawing_Size
$labTo.TabIndex = 11
$labTo.Text = "To:"
$formTrackLog.Controls.Add($labTo)
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 3
$System_Drawing_Point.Y = 67
$labSubject.Location = $System_Drawing_Point
$labSubject.Name = "labSubject"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 54
$labSubject.Size = $System_Drawing_Size
$labSubject.TabIndex = 11
$labSubject.Text = "Subject:"
$formTrackLog.Controls.Add($labSubject)
$System_Drawing_SizeCSV = New-Object System.Drawing.Size
$System_Drawing_SizeCSV.Width = 84
$System_Drawing_SizeCSV.Height = 24
$chkBoxCSV.Size = $System_Drawing_SizeCSV
$chkBoxCSV.TabIndex = 1
$chkBoxCSV.Text = "Export CSV"
$System_Drawing_PointCSV = New-Object System.Drawing.Point
$System_Drawing_PointCSV.X = 570
$System_Drawing_PointCSV.Y = 64
$chkBoxCSV.Location = $System_Drawing_PointCSV
$chkBoxCSV.DataBindings.DefaultDataSourceUpdateMode = 0
$chkBoxCSV.Name = "chkBoxCSV"
$formTrackLog.Controls.Add($chkBoxCSV)
$System_Drawing_SizeMail = New-Object System.Drawing.Size
$System_Drawing_SizeMail.Width = 90
$System_Drawing_SizeMail.Height = 24
$chkBoxMail.Size = $System_Drawing_SizeMail
$chkBoxMail.TabIndex = 1
$chkBoxMail.Text = "Send by mail"
$System_Drawing_PointMail = New-Object System.Drawing.Point
$System_Drawing_PointMail.X = 570
$System_Drawing_PointMail.Y = 34
$chkBoxMail.Location = $System_Drawing_PointMail
$chkBoxMail.DataBindings.DefaultDataSourceUpdateMode = 0
$chkBoxMail.Name = "chkBoxMail"
$formTrackLog.Controls.Add($chkBoxMail)
$txtBoxMail.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_PointMail = New-Object System.Drawing.Point
$System_Drawing_PointMail.X = 660
$System_Drawing_PointMail.Y = 34
$txtBoxMail.Location = $System_Drawing_PointMail
$txtBoxMail.Name = "txtBoxMail"
$System_Drawing_SizeMail = New-Object System.Drawing.Size
$System_Drawing_SizeMail.Height = 20
$System_Drawing_SizeMail.Width = 110
$txtBoxMail.Size = $System_Drawing_SizeMail
$txtBoxMail.TabIndex = 3
$txtBoxMail.Text = "SMTP Server"
$formTrackLog.Controls.Add($txtBoxMail)
$txtBoxFromMail.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_PointFromMail = New-Object System.Drawing.Point
$System_Drawing_PointFromMail.X = 775
$System_Drawing_PointFromMail.Y = 34
$txtBoxFromMail.Location = $System_Drawing_PointFromMail
$txtBoxFromMail.Name = "txtBoxFromMail"
$System_Drawing_SizeFromMail = New-Object System.Drawing.Size
$System_Drawing_SizeFromMail.Height = 20
$System_Drawing_SizeFromMail.Width = 110
$txtBoxFromMail.Size = $System_Drawing_SizeFromMail
$txtBoxFromMail.TabIndex = 3
$txtBoxFromMail.Text = "From"
$formTrackLog.Controls.Add($txtBoxFromMail)
$txtBoxToMail.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_PointToMail = New-Object System.Drawing.Point
$System_Drawing_PointToMail.X = 890
$System_Drawing_PointToMail.Y = 34
$txtBoxToMail.Location = $System_Drawing_PointToMail
$txtBoxToMail.Name = "txtBoxToMail"
$System_Drawing_SizeToMail = New-Object System.Drawing.Size
$System_Drawing_SizeToMail.Height = 20
$System_Drawing_SizeToMail.Width = 110
$txtBoxToMail.Size = $System_Drawing_SizeToMail
$txtBoxToMail.TabIndex = 3
$txtBoxToMail.Text = "To"
$formTrackLog.Controls.Add($txtBoxToMail)
$txtBoxCSV.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_PointTXTCSV = New-Object System.Drawing.Point
$System_Drawing_PointTXTCSV.X = 660
$System_Drawing_PointTXTCSV.Y = 65
$txtBoxCSV.Location = $System_Drawing_PointTXTCSV
$txtBoxCSV.Name = "txtBoxCSV"
$System_Drawing_SizeTXTCSV = New-Object System.Drawing.Size
$System_Drawing_SizeTXTCSV.Height = 20
$System_Drawing_SizeTXTCSV.Width = 250
$txtBoxCSV.Size = $System_Drawing_SizeTXTCSV
$txtBoxCSV.TabIndex = 3
$txtBoxCSV.Text = "Path to csv file"
$formTrackLog.Controls.Add($txtBoxCSV)
#endregion Generated Form Code
#Save the initial state of the form
$InitialFormWindowState = $formTrackLog.WindowState
#Init the OnLoad event to correct the initial state of the form
$formTrackLog.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$formTrackLog.ShowDialog()| Out-Null
} #End Function
#Call the Function
GenerateForm

252
powershell/exchange/Set-Webserver.ps1

@ -0,0 +1,252 @@
<#
.SYNOPSIS
Configures IIS log file settings
Thomas Stensitzki
THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
Version 1.1, 2016-07-28
Ideas, comments and suggestions to support@granikos.eu
Some parts (c) Michel de Rooij, michel@eightwone.com
.LINK
http://www.granikos.eu/en/scripts
.DESCRIPTION
This script reconfigures the IIS log folder to target a different folder besides the
default C:\inetpub\logs folder. Additionally the log settings can be adjusted as well.
The script changes the default log file location and settings on a server level. By
default the settings are inherited by websites. If manual changes have been made on
a webite level, not all settings will be inherited.
.NOTES
Requirements
- Windows Server 2008 R2 SP1, Windows Server 2012 or Windows Server 2012 R2
Revision History
--------------------------------------------------------------------------------
1.0 Initial community release
1.1 PowerShell hygiene applied, some typo fixes
.PARAMETER LogFolderPath
New IIS log folder path, i.e. D:\IISLogs. Default is an empty string.
.PARAMETER LogFilePeriod
Log file period (interval), Hourly|Daily|Weekly|Monthly|MaxSize
MaxSize configuration not yet implemented
.PARAMETER LocalTimeRollover
Boolean parameter indicating, if the local time shall be used for filenames and rollover
Default $FALSE
.EXAMPLE
Change the IIS log file location to D:\IISLogs
.\Set-Webserver.ps1 -LogFolderPath D:\IISLogs
.EXAMPLE
Change the IIS log period to an hourly period
.\Set-Webserver.ps1 -LogFilePeriod Hourly
.EXAMPLE
Use the local time for filenames and log file rollover
.\Set-Webserver.ps1 -LocalTimeRollover $true
#>
Param(
[parameter(Position=0,Mandatory=$false,ValueFromPipeline=$false,HelpMessage='New IIS log folder path, i.e. D:\IISLogs')]
[string]$LogFolderPath = '',
[parameter(Position=1,Mandatory=$false,ValueFromPipeline=$false,HelpMessage='Log file period (Hourly|Daily|Weekly|Monthly|MaxSize)')]
[string]$LogFilePeriod = '',
[parameter(Position=2,Mandatory=$false,ValueFromPipeline=$false,HelpMessage='$true/$false indicating, if the local time shall be used for filenames and rollover')]
[bool]$LocalTimeRollover=$false
)
process{
# log file property settings
$lfpDirectory = 'directory'
$lfpPeriod = 'period'
$lfpLocalTimeRollover = 'localTimeRollover'
# Check if folder exists, otherwise create folder
function Create-Folder
{
param
(
[string]
$folderPath
)
Write-Verbose "Evaluating IIS folder path: $folderPath"
if(-not ($folderPath -eq ''))
{
if(-not (Test-Path $folderPath))
{
Write-Host "Creating IIS log folder path: $folderPath"
New-Item -Path $folderPath -ItemType directory | Out-Null
}
else
{
Write-Host "Folder $folderPath already exsists"
}
}
}
# Change IIS log file setting
function ChangeIisLogSetting
{
param
(
[string]
$settingName,
[string]
$settingValue
)
try
{
Write-Verbose "Configuring IIS log setting $settingsName to value $settingsValue"
$logConfig = @{$settingName=$settingValue}
Set-WebConfigurationProperty 'system.applicationHost/sites/siteDefaults' -Name logFile -Value $logConfig
}
catch [system.exception]
{
Write-Host 'An error occured while trying to write IIS settings. Please check permissions of your account and ensure that PowerShell is running from an elevated prompt.' -ForegroundColor Red
}
}
# Change IIS default log location and other IIS log settings
function ChangeIisLogPath
{
param
(
[string]
$folderPath
)
Write-Verbose "IIS Log Folder Path to configure: $folderPath"
Write-Host "Configuring IIS default log location to '$folderPath'"
if(Test-Path $folderPath)
{
ChangeIisLogSetting $lfpDirectory $folderPath
}
else
{
Write-Host "New IIS log folder $folderPath does not exist. IIS log file folder configuration has not been changed" -ForegroundColor Red
}
}
# Change IIS log period
function ChangeIisLogPeriod
{
param
(
[string]
$logPeriod
)
if($AllowedLogFilePeriod -contains $logPeriod)
{
Write-Verbose "Changing IIS log periog to: $logPeriod"
ChangeIisLogSetting $lfpPeriod $logPeriod
}
}
# Change IIS LocalTimeRollover setting
function ChangeLocalTimeRollover
{
param
(
[bool]
$logLocalTimeRollover
)
Write-Verbose "Changing IIS log local time rollover to: $logLocalTimeRollover"
ChangeIisLogSetting $lfpLocalTimeRollover $logLocalTimeRollover
}
function CheckWindowsFeature
{
param
(
[string]
$MajorOSVersion
)
$featureInstalled = $false
If ($MajorOSVersion -eq '6.1')
{
Import-Module ServerManager
If(!(Get-Module ServerManager))
{
Write-Error 'Problem loading ServerManager module'
Exit 'ServerManager module could not be loaded!'
}
}
Write-Verbose "Checking, if Windows Feature 'Web-Server' is installed"
$feature = Get-WindowsFeature Web-Server
$featureInstalled = [bool]($feature.Installed)
Write-Verbose "Feature 'Web-Server' installed: $featureInstalled"
return( $featureInstalled )
}
## Main
Write-Verbose 'Script started'
$MajorOSVersion= [string](Get-WmiObject Win32_OperatingSystem | Select-Object Version | Select-Object @{n='Major';e={($_.Version.Split('.')[0]+'.'+$_.Version.Split('.')[1])}}).Major
$AllowedLogFilePeriod = @('Hourly','Daily','Weekly','Monthly') # MaxSize not yet implemented
if( CheckWindowsFeature($MajorOSVersion) )
{
Write-Verbose 'Configuring IIS log file settings'
if($LogFolderPath -ne '')
{
# Create IIS Log File Folder, independent from server role
Create-Folder $LogFolderPath
#Change log file settings
ChangeIisLogPath $LogFolderPath $LogFilePeriod
}
if($LogFilePeriod -ne '')
{
ChangeIisLogPeriod $LogFilePeriod
}
if($LocalTimeRollover -ne $null)
{
ChangeLocalTimeRollover $LocalTimeRollover
}
}
else
{
Write-Host 'IIS is currently not installed. Either add the windows feature manually or install Exchange first and adjust the IIS log file location afterwards.' -ForegroundColor Red
}
Write-Verbose 'Script ended'
} #Process

31
powershell/exchange/enable-ad-user-mailbox.ps1

@ -0,0 +1,31 @@
. 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'
Connect-ExchangeServer -auto
$LogFile="C:\add_ad_user_mail-$((Get-Date).ToString('yyyy-MM-dd')).log"
Start-Transcript -path $LogFile -append
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [Start]"
Import-module activedirectory
# $since=(Get-Date).AddDays(-4).ToUniversalTime().ToString('yyyyMMddHHmmss.fZ')
$since=(Get-Date).AddMinutes(-20).ToUniversalTime().ToString('yyyyMMddHHmmss.fZ')
$users=Get-ADUser -LDAPfilter "(&(objectCategory=person)(objectClass=user)(Name=*)(!(!UserPrincipalName=*))(whenCreated>=$since))" -searchBase 'CN=Users,DC=bloks,DC=local'
foreach($user in $users)
{
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [User] $($user.SamAccountName)"
if (Get-Mailbox -Identity $user.SamAccountName 2>$null)
{
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [User] $($user.SamAccountName): It's alive"
}
else
{
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [User] $($user.SamAccountName): enable mailbox"
Enable-Mailbox -Identity $user.SamAccountName
}
}
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [End]"
Stop-Transcript

176
shell/get_proc_mem.sh

@ -32,6 +32,164 @@ COLOR_GRAY="${COLOR_GRAY:-\e[1;90m}"
COLOR_OFF="${COLOR_OFF:-\e[0m}" COLOR_OFF="${COLOR_OFF:-\e[0m}"
NOCOLOR="${NOCOLOR:-false}" NOCOLOR="${NOCOLOR:-false}"
time_data=""
mem_total_data=""
mem_free_data=""
mem_available_data=""
mem_rss_data=""
mem_pss_data=""
mem_uss_data=""
cpu_used_data=""
trap trap::info 1 2 3 15 EXIT
######################################################################################################
# function
######################################################################################################
function trap::info() {
cat << EOF > pid_${PID}_line.json
option = {
title: {
text: '内存监控',
subtext: 'PID: ${PID}'
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['mem_total', 'mem_free', 'mem_available', 'pid_mem_rss', 'pid_mem_pss', 'pid_mem_uss', 'pid_cpu_used']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: [${time_data/,}]
},
yAxis: [
{
type: "value",
name: "内存 / MB",
nameLocation: 'center',
nameGap: 45
},
{
type: "value",
name: "CPU使用率 / %",
nameLocation: 'center',
nameGap: 45
}
],
series: [
{
name: 'mem_total',
type: 'line',
smooth: true,
data: [${mem_total_data/,}],
markPoint: {
data: [{
name: '最大值',
type: 'max'
}]
}
},
{
name: 'mem_free',
type: 'line',
smooth: true,
data: [${mem_free_data/,}],
markPoint: {
data: [{
name: '最小值',
type: 'min'
}]
}
},
{
name: 'mem_available',
type: 'line',
smooth: true,
data: [${mem_available_data/,}],
markPoint: {
data: [{
name: '最小值',
type: 'min'
}]
}
},
{
name: 'pid_mem_rss',
type: 'line',
smooth: true,
data: [${mem_rss_data/,}],
markPoint: {
data: [{
name: '最大值',
type: 'max'
}]
}
},
{
name: 'pid_mem_pss',
type: 'line',
smooth: true,
data: [${mem_pss_data/,}],
markPoint: {
data: [{
name: '最大值',
type: 'max'
}]
}
},
{
name: 'pid_mem_uss',
type: 'line',
smooth: true,
data: [${mem_uss_data/,}],
markPoint: {
data: [{
name: '最大值',
type: 'max'
}]
}
},
{
name: 'pid_cpu_used',
type: 'line',
smooth: true,
yAxisIndex: 1,
data: [${cpu_used_data/,}],
markPoint: {
data: [{
name: '最大值',
type: 'max'
}]
}
}
]
};
EOF
echo -e "
\n${COLOR_GREEN}
Config File: pid_${PID}_line.json
GO TO URL: https://echarts.apache.org/next/examples/en/editor.html
${COLOR_OFF}
"
trap '' EXIT
exit
}
###################################################################################################### ######################################################################################################
# function # function
###################################################################################################### ######################################################################################################
@ -43,6 +201,7 @@ function get::meminfo() {
pid_smaps=$(cat /proc/${PID}/smaps) pid_smaps=$(cat /proc/${PID}/smaps)
[ "$pid_smaps" == "" ] && { echo -e "${COLOR_RED}[Error]${COLOR_OFF} /proc/${PID}/smaps is empty!"; exit 1; } [ "$pid_smaps" == "" ] && { echo -e "${COLOR_RED}[Error]${COLOR_OFF} /proc/${PID}/smaps is empty!"; exit 1; }
cpu_used=$(ps -opcpu= -p "${PID}")
mem_info=$(cat /proc/meminfo) mem_info=$(cat /proc/meminfo)
mem_total=$(printf "%s" "${mem_info}"| awk '/^MemTotal:/ {print $2}') mem_total=$(printf "%s" "${mem_info}"| awk '/^MemTotal:/ {print $2}')
@ -77,7 +236,22 @@ function get::meminfo_loop() {
get::pidinfo get::pidinfo
while [ $count -lt $RETRIES ] ; do while [ $count -lt $RETRIES ] ; do
get::meminfo get::meminfo
echo -e "Date: $(date +'%Y-%m-%d %T') ${COLOR_PURPLE}MemTotal: $((mem_total/1024))MB${COLOR_OFF} ${COLOR_GREEN}MemFree: $((mem_free/1024))MB${COLOR_OFF} ${COLOR_BLUE}MemAvailable: $((mem_available/1024))MB${COLOR_OFF} ${COLOR_YELLOW}RSS: $((${rss}/1024))MB${COLOR_OFF} ${COLOR_CYAN}PSS: $((${pss}/1024))MB${COLOR_OFF} ${COLOR_RED}USS: $(( (${private_clean} + ${private_dirty}) /1024 ))MB${COLOR_OFF}" d=$(date +'%Y-%m-%d %T')
mem_total=$((mem_total/1024))
mem_free=$((mem_free/1024))
mem_available=$((mem_available/1024))
mem_rss=$((${rss}/1024))
mem_pss=$((${pss}/1024))
mem_uss=$(( (${private_clean} + ${private_dirty}) /1024 ))
echo -e "Date: ${d} ${COLOR_PURPLE}MemTotal: ${mem_total}MB${COLOR_OFF} ${COLOR_GREEN}MemFree: ${mem_free}MB${COLOR_OFF} ${COLOR_BLUE}MemAvailable: ${mem_available}MB${COLOR_OFF} ${COLOR_YELLOW}RSS: ${mem_rss}MB${COLOR_OFF} ${COLOR_CYAN}PSS: ${mem_pss}MB${COLOR_OFF} ${COLOR_RED}USS: ${mem_uss}MB${COLOR_OFF} CPU: ${cpu_used}%"
time_data="${time_data},'${d}'"
mem_total_data="${mem_total_data},'${mem_total}'"
mem_free_data="${mem_free_data},'${mem_free}'"
mem_available_data="${mem_available_data},'${mem_available}'"
mem_rss_data="${mem_rss_data},'${mem_rss}'"
mem_uss_data="${mem_uss_data},'${mem_uss}'"
mem_pss_data="${mem_pss_data},'${mem_pss}'"
cpu_used_data="${cpu_used_data},'${cpu_used}'"
sleep $WAIT sleep $WAIT
count=$(($count + 1)) count=$(($count + 1))
done done

2
shell/k8s/k8s-app-info.sh

@ -61,7 +61,7 @@ function get::selector {
echo -ne "Get Selector" echo -ne "Get Selector"
if [[ "${SELECTOR}" == "" ]]; then if [[ "${SELECTOR}" == "" ]]; then
selflink=$(kubectl -n $NAMESPACE get deployment $APPNAME -o yaml --ignore-not-found 2>/dev/null | awk '/selfLink:/ {print $2}') selflink=$(kubectl -n $NAMESPACE get deployment $APPNAME -o yaml --ignore-not-found 2>/dev/null | awk '/selfLink:/ {print $2}')
SELECTOR=$(kubectl get --raw "${selflink}/scale" 2>/dev/null | sed 's/.*selector":"\(.*\)".*/\1/g') SELECTOR=$(kubectl get --raw "${selflink}/scale" 2>/dev/null | sed 's/.*[S|s]elector":"\(.*\)".*/\1/g')
fi fi
if [[ "${SELECTOR}" == "" ]]; then if [[ "${SELECTOR}" == "" ]]; then

Loading…
Cancel
Save