• Home
  • PS
  • C#
  • Perl
  • MSSQL
  • MariaDB
  • Linux
  • Docker
  • MacOS
  • PG
  • Exchange Server
  • Windows
  • Other

Home

Reset-ComputerMachinePassword

Details
Written by: po3dno
Category: Windows
Created: 01 September 2023
Hits: 457

Resets the machine account password for the computer.

Syntax

PowerShell
 
Reset-ComputerMachinePassword
     [-Server <String>]
     [-Credential <PSCredential>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]

Description

The Reset-ComputerMachinePassword cmdlet changes the computer account password that the computers use to authenticate to the domain controllers in the domain. You can use it to reset the password of the local computer.

Examples

Example 1: Reset the password for the local computer

PowerShell
 
Reset-ComputerMachinePassword

This command resets the computer password for the local computer. The command runs with the credentials of the current user.

Example 2: Reset the password for the local computer by using a specified domain controller

PowerShell
 
Reset-ComputerMachinePassword -Server "DC01" -Credential Domain01\Admin01

This command resets the computer password of the local computer by using the DC01 domain controller. It uses the Credential parameter to specify a user account that has permission to reset a computer password in the domain.

Example 3: Reset the password on a remote computer

PowerShell
 
$cred = Get-Credential
Invoke-Command -ComputerName "Server01" -ScriptBlock {Reset-ComputerMachinePassword -Credential $using:cred}

This command uses the Invoke-Command cmdlet to run a Reset-ComputerMachinePassword command on the Server01 remote computer.

For more information about remote commands in Windows PowerShell, see about_Remote and Invoke-Command.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Aliases: cf
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Credential

Specifies a user account that has permission to perform this action. The default is the current user.

Type a user name, such as User01 or Domain01\User01, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, this cmdlet prompts you for a password.

This parameter was introduced in Windows PowerShell 3.0.

Type: PSCredential
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Server

Specifies the name of a domain controller to use when this cmdlet sets the computer account password.

This parameter is optional. If you omit this parameter, a domain controller is chosen to service the command.

Type: String
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Aliases: wi
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

Сброс пароля компьютера в домене без перезагрузки

Details
Written by: po3dno
Category: Windows
Created: 01 September 2023
Hits: 432

В таких случаях, системный администратор обычно просто заново включал вылетевший компьютер в домен. Но для этого компьютер нужно перезагружать. Мне захотелось найти альтернативу такому решению, и как оказалось, оно существует. Для этого можно воспользоваться Powershell.

  • Откройте консоль PowerShell
  • Введите команду
    Test-ComputerSecureChannel

    powershell тестируем связьс доменом

  • Если в ответ мы получим False, это означает что невозможно установить безопасный канал между клиентом и контроллером домена. А т.к. не устанавливается безопасный канал, то и залогинится с доменной учетной записью нельзя.
  • Чтобы сбросить и синхронизировать пароль компьютера в домене, воспользуемся командой
    Test-ComputerSecureChannel –Credential  -Repair

    reset computer account in AD

  • В появившемся окне введите имя пользователя, которому разрешено управлять учетной записью компьютера в домене и его пароль
  • После чего еще раз проверим возможность установки безопасного канала первой командой, если все получилось, она вернет True
  • Осталось выйти из системы и зайти под доменной учетной записью

sqlserver

Details
Written by: po3dno
Category: MSSQL
Created: 08 August 2023
Hits: 410

[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($proxy)
[system.net.webrequest]::defaultwebproxy.credentials = $cred
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
Register-PSRepository -Default
Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2

Install-Module sqlserver -Proxy $proxy -ProxyCredential $cred

Image optimization

Details
Written by: po3dno
Category: Windows
Created: 03 August 2023
Hits: 391

After applying updates to a Windows image, cleanup the image and then export it to a new file:

md c:\mount\Windows
md C:\mount\temp

Dism /Mount-Image /ImageFile:"C:\Images\install.wim" /Index:1 /MountDir:C:\mount\Windows

Dism /Cleanup-Image /Image=C:\mount\Windows /StartComponentCleanup /ResetBase /ScratchDir:C:\mount\temp

Dism /Unmount-Image /MountDir:C:\mount\Windows /Commit

Dism /Export-Image /SourceImageFile:C:\Images\install.wim /SourceIndex:1 /DestinationImageFile:C:\Images\install_cleaned.wim

How to Convert OVA/OVF to VHD/VHDX with Command Line?

Details
Written by: po3dno
Category: Other
Created: 02 August 2023
Hits: 500

Virtual environment helps companies a lot but for IT administrators it requires new knowledge to manage VMs. Virtual machine management is different from physical machine management, especially in server migration.

Migrating physical machine requires complicated procedures to prepare hardware and copy data but virtual machine just consists of multiple files so moving virtual machine just requires exporting and importing data.

The difficulty during VM migration might be booting VM on a foreign hypervisor because the image often needs to be preprocessed before being imported to another host. In other words, a V2V converter is often needed during the migration procedures.

VMware users can export virtual machine to OVF or OVA template via OVF Tool. OVF is a folder and OVA contains nearly the same information like OVF but it's a zip file. Some virtual machine management tools like Xen Orchestra can directly recognize VMware template but Hyper-V doesn't have such a tool.

You can just import an entire Hyper-V VM or vhd/vhdx virtual disk to Hyper-V host so if you have an OVA or OVF template, you can convert it to vhd/vhdx virtual disk to import it to Hyper-V host.

Convert OVA/OVF to VHD/VHDX with Powershell

The entire VM template contains all the VM data like applications, snapshots, and configuration but all you need is the virtual disk for data migration and VMware virtual disk is saved as vmdk format. You can directly extract the vmdk file from OVF template and for OVA template, you also just need to unzip the file to find the vmdk file.

Now you need to install some applications on the local machine before converting the virtual disk. Make sure Microsoft Virtual Machine Converter 3.0 and PowerShell are installed on the local machine and then you can type the command below in PowerShell.

Import the Microsoft Converter Powershell Module:

Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"

Convert the vmdk virtual disk to vhdx format:

ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "virtual_disk_directory.vmdk" -DestinationLiteralPath "virtual_disk_directory.vhdx" -VhdType DynamicHardDisk -VhdFormat Vhdx

After that, you can create a new VM with the vhdx virtual disk or attach it to an existing VM.

Convert VMware virtual disk to VHD/VHDX with qemu-img

There is another conversion tool for convert the VMware virtual disk in OVF/OVA template, qemu-img, which supports converting multiple formats of virtual disks like vmdk, qcow2, raw, vhdx, etc.

You just need the command below:

qemu-img convert -f vmdk -O vhdx virtual_disk_directory.vmdk virtual_disk_directory.vhdx

Convert virtual disk for Hyper-V with VirtualBox

This doesn't mean you need to deploy related virtual environment. You just need the VirtualBox application and then use the command to convert the virtual disk. You even don't have to open the application after you install it on local machine.

VBoxManage.exe clonehd --format vhd "virtual_disk_directory.vmdk" "virtual_disk_directory.vhd"

  1. ConvertTo-MvmcVirtualHardDisk The entry is not a supported disk database entry...
  2. WSUS tunning 2
  3. Language pack offline install
  4. Rebuild search Index

Subcategories

Power Shell Article Count:  53

C# Article Count:  10

Perl Article Count:  1

Exchange Server Article Count:  15

Other Article Count:  24

MSSQL Article Count:  17

Windows Article Count:  25

MariaDB Article Count:  3

Linux Article Count:  7

Docker Article Count:  2

pg Article Count:  1

Page 5 of 32

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

Login Form

  • Forgot your password?
  • Forgot your username?

Statistics

  • Users 2
  • Articles 165
  • Articles View Hits 151306