Using remote-exec to run powershell script on destroy

Hi ,

I need to run powershell script to delete ad object and dns entry before destroying the ec2 , will it be possible using remote-exec at destroy ??
It’s windows environment , main aim is to delete those ad object of ec2 which we are destroying and dns entry so that in case the same name is used to create ec2 it will not cause any issues.
Many thanks