This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Push-Location $PSScriptRoot | |
$Info = Get-Content 'info.txt' -Raw | ConvertFrom-Csv -Delimiter "`t" -WarningAction SilentlyContinue | |
$Mac = (Get-NetAdapter -Physical | ? {$_.MediaType -eq '802.3'} | select -First 1 -ExpandProperty MacAddress) -replace '-', ':' | |
$NewName = $Info | ? {$_.MACアドレス -eq $Mac} | select -First 1 -ExpandProperty コンピュータ名 | |
$CurrentName = $env:COMPUTERNAME | |
if((Get-WmiObject Win32_ComputerSystem).PartOfDomain){ | |
Write-Warning 'AD参加済みのPCです' | |
} | |
elseif([string]::IsNullOrEmpty($NewName)){ | |
Write-Warning '"info.txt"からPC名が取得できませんでした' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# まず ChatGPT を使うための各種パラメータを指定します。 | |
$Token = 'ここにAPIキーを入れてください' | |
$Uri = 'https://api.openai.com/v1/chat/completions' | |
$PostBody = @{ | |
model = 'gpt-3.5-turbo' | |
} | |
# 次に質問する文章を決めます。 | |
$PostBody.messages = @( | |
@{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Compress-Png { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory, Position = 0, ValueFromPipeline)] | |
[string]$InputFile, | |
[Parameter(Mandatory, Position = 1)] | |
[string]$OutFile | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Convert domain name list to byte array | |
.DESCRIPTION | |
Encodes a list of domain names into the format specified in Section 4.1.4 of "Domain Names - Implementation And Specification" (RFC 1035). | |
.EXAMPLE | |
PS C:\> Convert-DomainListToByteArray ('foo.example.com', 'example.com') | |
.PARAMETER DomainList | |
Specifies a List of domains | |
.INPUTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original code is written by earthdiver1 | |
# https://qiita.com/earthdiver1/items/0b9c85a5f2c90ba51f7e | |
# Modified by mkht | |
function Send-ARPRequest { | |
[CmdletBinding(PositionalBinding = $False)] | |
[Alias('arping')] | |
Param( | |
[Parameter(Position = 0)] | |
[String]$Target, # IP address of the target host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using module PSWebDriver | |
Describe 'DuckDuckGo' { | |
BeforeAll { | |
$Browser = New-PSWebDriver 'Chrome' | |
} | |
It 'DuckDuckGoで「PowerShell」を検索' { | |
#ブラウザを起動 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'CollectUpdates.vbs | |
'This script is written by Microsoft | |
'https://docs.microsoft.com/en-us/previous-versions/office/office-2013-resource-kit/cc178995(v=office.15)#testing-and-verifying-the-windows-installer-msp-files | |
Dim oMsi,oFso,oWShell | |
Dim Patches,SumInfo | |
Dim patch,record,msp | |
Dim qView | |
Dim sTargetFolder,sMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Compress-ScriptBlock { | |
[CmdletBinding()] | |
[Alias('minify')] | |
[OutputType([scriptblock])] | |
param ( | |
[Parameter(Mandatory, Position = 0, ValueFromPipeline)] | |
[ValidateNotNullOrEmpty()] | |
[scriptblock] | |
$ScriptBlock | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'Stop' | |
cd C:\ | |
$null = New-Item C:\j\k\l -ItemType Directory -Force | |
$null = Get-ChildItem C:\j\k | Select-Object -First 1 | |
Remove-Item C:\j\k -Recurse -Force | |
Start-Sleep -Seconds 3 | |
Remove-Item C:\j\k -Recurse -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<###################################################### | |
# Windows PE 作成スクリプト | |
#######################################################> | |
$ErrorActionPreference = 'Stop' | |
Set-Location $PSScriptRoot | |
$script:WorkDir = Join-Path $PSScriptRoot '\Work' | |
if (Test-Path $script:WorkDir -PathType Container -ErrorAction Ignore) { | |
Remove-Item $script:WorkDir -Force -Recurse | |
} | |
$null = New-Item $script:WorkDir -ItemType Directory -Force |
NewerOlder