change logic to powershell