Home
- Details
- Written by: po3dno
- Category: Power Shell
- Hits: 488
This post explains how to work with ODBC connections in Powershell. Powershell 4 introduced new cmdlets that make it very easy to create and manage ODBC connections. We use the .NET assembly system.data.odbc.odbcconnection to use ODBC connections present on the system to query the database.
ODBC connections in Powershell 4.0 and higher
Powershell 4 introduced these 4 cmdlets to create, manage and remove ODBC connections. If you for some reason still are on Powershell 3.0, I recommend you to upgrade to Powershell 5.0 which is the newest version at the time of this blog post. Managing ODBC connections in Powershell 3 or older is not fun and requires you to either modify registry or use an .exe file to manage them for you.
- Add-OdbcDsn
- Get-OdbcDsn
- Remove-OdbcDsn
- Set-OdbcDsn
- Details
- Written by: po3dno
- Category: Windows
- Hits: 334
Если перед запуском обновления Inplace заданы следующие записи реестра, Windows 11 больше не отображает мастер приветствия для этого пользователя при первом входе в систему (записи относятся к HKCU, поэтому они связаны с пользователем). Вот обязательные записи:
необходимо ввести в соответствующую учетную запись пользователя в Windows 10 перед обновлением. Записи реестра можно установить с помощью пакетной программы. Маркус отметил, что в более крупных средах записи, безусловно, можно развертывать через GPO. Если все работает, Мастер приветствия больше не должен доставлять неудобства.
- Details
- Written by: po3dno
- Category: Power Shell
- Hits: 366
(New-Object -ComObject Microsoft.Update.Session).CreateupdateSearcher().Search("IsHidden=0 and IsInstalled=0").Updates | Select-Object Title
Stop-Service -Name BITS, wuauserv -Force
Remove-ItemProperty -Name AccountDomainSid, PingID, SusClientId, SusClientIDValidation -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\ -ErrorAction SilentlyContinue
Remove-Item "$env:SystemRoot\SoftwareDistribution\" -Recurse -Force -ErrorAction SilentlyContinue
Start-Service -Name BITS, wuauserv
wuauclt /resetauthorization /detectnow
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()
- Details
- Written by: po3dno
- Category: Other
- Hits: 502
diskpart (opens Disk Partitioning tool)
select disk 0
list volume (please note the number of the volume that has no drive letter assigned and has FAT32 listed in Fs column)
select volume <the number of ~500 MB FAT32 volume with no drive letter, or with label ESP>
assign letter=Z: (gives drive letter Z: to EFI System Partition)
exit (closes Disk Partitioning tool)
cd /d Z:\EFI\Microsoft\Boot\ (changes current folder in Command Prompt window)
attrib Z:\EFI\Microsoft\Boot\BCD -h -r -s (removes hidden, read-only and system attributes from BCD folder)
ren Z:\EFI\Microsoft\Boot\BCD BCD.old (renames BCD folder to BCD.old)
bootrec /rebuildbcd (retries the rebuild)
- Details
- Written by: po3dno
- Category: Power Shell
- Hits: 571
Function New-ISOFileFromFolder{
<#
.SYNOPSIS
Creates an ISO file from a filepath
#>
param(
[Parameter(Mandatory=$true)]
[String]$FilePath,
[Parameter(Mandatory=$true)]
[String]$Name,
[Parameter(Mandatory=$true)]
[String]$ResultFullFileName
)
write-host "Creating ISO $Name" -ForegroundColor Green
$fsi = New-Object -ComObject IMAPI2FS.MsftFileSystemImage
$dftd = New-Object -ComObject IMAPI2.MsftDiscFormat2Data
$Recorder = New-Object -ComObject IMAPI2.MsftDiscRecorder2
$fsi.FileSystemsToCreate = 7
$fsi.VolumeName = $Name
$fsi.FreeMediaBlocks = 1000000 #default 332800
$fsi.Root.AddTreeWithNamedStreams($FilePath,$false)
$resultimage = $fsi.CreateResultImage()
$resultStream = $resultimage.ImageStream
Write-IStreamToFile $resultStream $ResultFullFileName
}