Home
- Details
- Written by: po3dno
- Category: Power Shell
- Hits: 71
(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: 153
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: 232
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
}
- Details
- Written by: po3dno
- Category: Power Shell
- Hits: 1291
function Get-RandomPassword {
param (
[Parameter(Mandatory)]
[int] $length,
[int] $amountOfNonAlphanumeric = 1
)
Add-Type -AssemblyName 'System.Web'
return [System.Web.Security.Membership]::GeneratePassword($length, $amountOfNonAlphanumeric)
}
"user1
user2" -split "`n" | %{$user = $_; $pwdplain = $(Get-RandomPassword 8); New-ADUser -Name $user -AccountPassword $(ConvertTo-SecureString -String $pwdplain -AsPlainText -Force) -Enabled $true; write-host $user $pwdplain}
- Details
- Written by: po3dno
- Category: Windows
- Hits: 264
When you join a machine to the domain, by default it will be placed in the Computers container under the root of the domain. This can be undesirable, particularly if you want to apply distinct Group Policy to machines when they are initially joined to the domain. Fortunately, Active Directory lets you change the default location for new Computer accounts. The best way to make this change is with the redircmp tool that is included with Windows Server. For example, to redirect new computers in the cohovines.com domain to an Organizational Unit called NewComputers, run this command:
redircmp "OU=NewComputers,DC=cohovines,DC=com"
Under the covers, the redircmp tool updates an attribute of the domain NC head object called wellKnownObjects. The wellKnownObjects attribute contains a list of well known GUIDs and a distinguished name for each GUID. By using GUIDs, the path to an object can be dynamic without the client needing to be aware of anything other than the GUID for the object it is searching for. In this case, the aa312825-7688-11d1-aded-00c04fd8d5cd GUID is how Active Directory keeps track of the default location for new computer objects. You can use a tool like LDP to look at the wellKnownObjects attribute of the domain as shown below: