$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) if (-not ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { Write-Warning “This script needs to be running as the administrator.” Exit 1 } Write-Host “You are running as the administrator.” This script gets the current Windows Identity, then queries it to find out if it has the appropriate role.
Tag Archives: authorisation
Moving Databases
If you ever move a database from one SQL Server to another you may come across the situation where the logins no longer map to the users in your database (and that’s assuming that the SQL Server you’ve moved the database to has the same logins). If the new SQL Server does have the same …