{"id":2264,"date":"2022-10-27T08:02:30","date_gmt":"2022-10-27T08:02:30","guid":{"rendered":"https:\/\/sunucucozumleri.com\/?p=2264"},"modified":"2022-10-21T21:07:55","modified_gmt":"2022-10-21T21:07:55","slug":"powershell-ile-windows-rds-sunucusu-icin-120-gunluk-sureyi-sifirlamak-grace-period-reset","status":"publish","type":"post","link":"https:\/\/sunucucozumleri.com\/blog\/powershell-ile-windows-rds-sunucusu-icin-120-gunluk-sureyi-sifirlamak-grace-period-reset\/","title":{"rendered":"PowerShell ile Windows RDS Sunucusu i\u00e7in 120 G\u00fcnl\u00fck S\u00fcreyi S\u0131f\u0131rlamak &#8211; Grace Period Reset"},"content":{"rendered":"<p dir=\"auto\"><span>Hangi nedenle olursa olsun, <a href=\"https:\/\/sunucucozumleri.com\/sunucu\/sanal-sunucu\/\">sanal sunucu<\/a> veya <a href=\"https:\/\/sunucucozumleri.com\/sunucu\/sunucu-kiralama\/\">fiziksel sunucu<\/a>nuzda Windows RDS sunucusu (uzak masa\u00fcst\u00fc hizmetleri, di\u011fer ad\u0131yla terminal sunucusu) i\u00e7in \u00f6demesiz s\u00fcreyi uzatman\u0131z gereken bir durumla kar\u015f\u0131la\u015fabilirsiniz. <a href=\"https:\/\/sunucucozumleri.com\/blog\/frontpage\/\">sunucu<\/a>. Windows Server 2012 ve Server 2012 R2 d\u00f6neminde Microsoft, bu senaryo i\u00e7in a\u015fa\u011f\u0131daki PowerShell beti\u011fini sa\u011flad\u0131.\u00a0Ancak art\u0131k senaryoyu test etmiyor veya bak\u0131m\u0131n\u0131 yapm\u0131yorlar.\u00a0Windows Server 2016&#8217;da test ettim ve kesinlikle hala \u00e7al\u0131\u015f\u0131yor.<\/span><\/p>\n<p dir=\"auto\"><span>Komut dosyas\u0131n\u0131 kullanmak i\u00e7in RDS sunucunuza kaydetmeniz ve y\u00fckseltilmi\u015f bir PowerShell isteminde \u00e7al\u0131\u015ft\u0131rman\u0131z yeterlidir.\u00a0Komut dosyas\u0131 etkile\u015fimlidir ve size ka\u00e7 g\u00fcn kald\u0131\u011f\u0131n\u0131 s\u00f6yleyecektir (bu \u015fekilde \u00e7ok h\u0131zl\u0131 bir \u015fekilde bakabilece\u011finiz i\u00e7in \u00e7ok kullan\u0131\u015fl\u0131d\u0131r) ve zaman\u0131 s\u0131f\u0131rlamak isteyip istemedi\u011finizi se\u00e7menize izin verir.<\/span><\/p>\n<p><code><br \/>\n## This Script is intended to be used for Querying remaining time and resetting Terminal Server (RDS) Grace Licensing Period to Default 120 Days.<br \/>\n## Developed by sunucucozumleri.com<br \/>\n## https:\/\/sunucucozumleri.com<br \/>\n## Disclaimer: Please test this script in your test environment before executing on any production server.<br \/>\n## Author will not be responsible for any misuse\/damage caused by using it. <\/p>\n<p>Clear-Host<br \/>\n$ErrorActionPreference = \"SilentlyContinue\" <\/p>\n<p>## Display current Status of remaining days from Grace period.<br \/>\n$GracePeriod = (Invoke-WmiMethod -PATH (gwmi -namespace root\\cimv2\\terminalservices -class win32_terminalservicesetting).__PATH -name GetGracePeriodDays).daysleft<br \/>\nWrite-Host -fore Green ======================================================<br \/>\nWrite-Host -fore Green 'Terminal Server (RDS) grace period Days remaining are' : $GracePeriod<br \/>\nWrite-Host -fore Green ======================================================<br \/>\nWrite-Host<br \/>\n$Response = Read-Host \"Do you want to reset Terminal Server (RDS) Grace period to Default 120 Days ? (Y\/N)\" <\/p>\n<p>if ($Response -eq \"Y\") {<br \/>\n## Reset Terminal Services Grace period to 120 Days <\/p>\n<p>$definition = @\"<br \/>\nusing System;<br \/>\nusing System.Runtime.InteropServices;<br \/>\nnamespace Win32Api<br \/>\n{<br \/>\n    public class NtDll<br \/>\n    {<br \/>\n        [DllImport(\"ntdll.dll\", EntryPoint=\"RtlAdjustPrivilege\")]<br \/>\n        public static extern int RtlAdjustPrivilege(ulong Privilege, bool Enable, bool CurrentThread, ref bool Enabled);<br \/>\n    }<br \/>\n}<br \/>\n\"@  <\/p>\n<p>Add-Type -TypeDefinition $definition -PassThru <\/p>\n<p>$bEnabled = $false <\/p>\n<p>## Enable SeTakeOwnershipPrivilege<br \/>\n$res = [Win32Api.NtDll]::RtlAdjustPrivilege(9, $true, $false, [ref]$bEnabled) <\/p>\n<p>## Take Ownership on the Key<br \/>\n$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey(\"SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\RCM\\GracePeriod\", [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree,[System.Security.AccessControl.RegistryRights]::takeownership)<br \/>\n$acl = $key.GetAccessControl()<br \/>\n$acl.SetOwner([System.Security.Principal.NTAccount]\"Administrators\")<br \/>\n$key.SetAccessControl($acl) <\/p>\n<p>## Assign Full Controll permissions to Administrators on the key.<br \/>\n$rule = New-Object System.Security.AccessControl.RegistryAccessRule (\"Administrators\",\"FullControl\",\"Allow\")<br \/>\n$acl.SetAccessRule($rule)<br \/>\n$key.SetAccessControl($acl) <\/p>\n<p>## Finally Delete the key which resets the Grace Period counter to 120 Days.<br \/>\nRemove-Item 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\RCM\\GracePeriod' <\/p>\n<p>write-host<br \/>\nWrite-host -ForegroundColor Red 'Resetting, Please Wait....'<br \/>\nStart-Sleep -Seconds 10  <\/p>\n<p>  } <\/p>\n<p>Else<br \/>\n    {<br \/>\nWrite-Host<br \/>\nWrite-Host -ForegroundColor Yellow '**You Chose not to reset Grace period of Terminal Server (RDS) Licensing'<br \/>\n  } <\/p>\n<p>## Display Remaining Days again as final status<br \/>\ntlsbln.exe<br \/>\n$GracePost = (Invoke-WmiMethod -PATH (gwmi -namespace root\\cimv2\\terminalservices -class win32_terminalservicesetting).__PATH -name GetGracePeriodDays).daysleft<br \/>\nWrite-Host<br \/>\nWrite-Host -fore Yellow =====================================================<br \/>\nWrite-Host -fore Yellow 'Terminal Server (RDS) grace period Days remaining are' : $GracePost<br \/>\nWrite-Host -fore Yellow ===================================================== <\/p>\n<p>## Cleanup of Variables<br \/>\nRemove-Variable * -ErrorAction SilentlyContinue<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hangi nedenle olursa olsun, sanal sunucu veya fiziksel sunucunuzda Windows RDS sunucusu (uzak masa\u00fcst\u00fc hizmetleri, di\u011fer ad\u0131yla terminal sunucusu) i\u00e7in \u00f6demesiz s\u00fcreyi uzatman\u0131z gereken bir durumla kar\u015f\u0131la\u015fabilirsiniz. sunucu. Windows Server 2012 ve Server 2012 R2 d\u00f6neminde Microsoft, bu senaryo i\u00e7in a\u015fa\u011f\u0131daki PowerShell beti\u011fini sa\u011flad\u0131.\u00a0Ancak art\u0131k senaryoyu test etmiyor veya bak\u0131m\u0131n\u0131 yapm\u0131yorlar.\u00a0Windows Server 2016&#8217;da test ettim &hellip;<\/p>\n","protected":false},"author":1,"featured_media":1476,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-2264","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts\/2264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/comments?post=2264"}],"version-history":[{"count":0,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/posts\/2264\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/media\/1476"}],"wp:attachment":[{"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/media?parent=2264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/categories?post=2264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunucucozumleri.com\/blog\/wp-json\/wp\/v2\/tags?post=2264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}