前書き
- ソースはインターネットから参照し、自分が動作確認済み
- 参照先は省略
PowerShellコマンド
Teamsと連携
Teamsと連携
Connect-MgGraph -Scopes "Chat.ReadWrite, ChannelMessage.Send"
Get-MgChat -All | Select-Object Id, Topic > d:\temp.txt
Get-MgChat -All | Where-Object {$_.Topic -like '*社員群*'}
$chatId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$params = @{ body = @{ content = "PowerShell send message to Teams:Hello World2" }}
New-MgChatMessage -ChatId $chatId -BodyParameter $params
MSMQと連携
MSMQ メッセージ送信
[Reflection.Assembly]::LoadWithPartialName("System.Messaging")
function WriteMessageToMSMQ($queueName, $message, $label) {
$utf8 = new-object System.Text.UTF8Encoding
$msgBytes = $utf8.GetBytes($message)
$msgStream = new-object System.IO.MemoryStream
$msgStream.Write($msgBytes, 0, $msgBytes.Length)
$msg = new-object System.Messaging.Message
$msg.BodyStream = $msgStream
if ($label -ne $null) {
$msg.Label = $label
}
$queue = new-object System.Messaging.MessageQueue $queueName
$queue.Send($msg)
Write-Host "Message written"
}
#-------------------------
#Test the above functions
#-------------------------
cls #clear screen (junk from prior runs)
$queueName = ".\Private$\Test"
$message = "This is my first test message"
WriteMessageToMSMQ $queueName $message $null
$message = "This is my second test message"
WriteMessageToMSMQ $queueName $message "MyLabel"
Write-Host "Completed"
MSMQ メッセージ受信
[Reflection.Assembly]::LoadWithPartialName("System.Messaging")
function ReadMessageFromMSMQ($queueName) {
$queue = new-object System.Messaging.MessageQueue $queueName
$utf8 = new-object System.Text.UTF8Encoding
$msgs = $queue.GetAllMessages()
write-host "Number of messages=$($msgs.Length)"
foreach ($msg in $msgs) {
write-host $msg_.Id
write-host $utf8.GetString($msg.BodyStream.ToArray())
}
$queue.Purge() #Clear All Message
}
#-------------------------
#Test the above functions
#-------------------------
cls #clear screen (junk from prior runs)
$queueName = ".\Private$\Test"
ReadMessageFromMSMQ $queueName
Write-Host "Completed"
環境変数設定
[Environment]::SetEnvironmentVariable("NODE_PATH", "C:\aaa\nodejs\", "User")
TypeScript サンプル
日付フォーマット
DateFormat(dateObj: Date): string {
let sss: string = dateObj.getFullYear() + "."
+ this._ZeroPadding((dateObj.getMonth() + 1), 2) + "."
+ this._ZeroPadding(dateObj.getDate(), 2) + "-"
+ this._ZeroPadding(dateObj.getHours(), 2) + "."
+ this._ZeroPadding(dateObj.getMinutes(), 2) + "."
+ this._ZeroPadding(dateObj.getSeconds(), 2);
return sss;
}
「0」を埋める
_ZeroPadding(num: number, len: number){
return ( Array(len).join('0') + num ).slice( -len );
}
SVNコマンド
フォルダのみ残し、ファイルをコミットしない。
svn propset svn:ignore * .