AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 03.02.2018, 01:15   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
yetanotherdynamicsaxblog: PowerShell script to toggle Maintenance mode
Источник: http://yetanotherdynamicsaxblog.blog...intenance.html
==============

In order to change licence configurations on Operations, you need to toggle maintenance mode on or off. This can be done using a Setup tool, but on the development machines where we do not have local admin rights, the only solution would be to hack the database, like Kurt Hatlevik shows us in this blog post.

In this post I will show how you can toggle maintenance mode on or off using PowerShell. The script is intended for OneBox environments. Just paste it into a new ps1 file for future use, or run it through PowerShell ISE.

DISCLAIMER: Don't run this unless you are prepared to take the heat from restarting the entire web application. It stops and starts the web server.

function ToggleMaintenanceMode()
{
$parm = @{
ServerInstance = 'localhost'
Database = 'AxDB'
Query = "UPDATE SQLSYSTEMVARIABLES SET [VALUE] = IIF([VALUE]=1, 0, 1) WHERE PARM = 'CONFIGURATIONMODE'"
}

Get-Service "W3SVC" | Stop-Service -Force
Invoke-Sqlcmd @parm
Get-Service "W3SVC" | Start-Service

$parm.Query = "SELECT [VALUE] FROM SQLSYSTEMVARIABLES WHERE PARM = 'CONFIGURATIONMODE'"
$result = Invoke-Sqlcmd @parm
[int]$value = $result.Value

Write-Output "Configuration mode $(('disabled','enabled')[$value])"
}

ToggleMaintenanceMode

The script shows you how you can easily run SQL commands, and even retrieve values back to your PowerShell script.

Enjoy!



Источник: http://yetanotherdynamicsaxblog.blog...intenance.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
yetanotherdynamicsaxblog: PowerShell script for synchronizing the database Blog bot DAX Blogs 0 28.01.2018 22:12
yetanotherdynamicsaxblog: List hotfixes using PowerShell in D365FO (AX7) Blog bot DAX Blogs 0 13.01.2018 20:21
palleagermark: Simple PowerShell deployment script for AOD based AX versions (i.e. earlier than AX 2012) Blog bot DAX Blogs 0 14.10.2013 10:11
PowerShell Script to Run As A Different User Blog bot DAX Blogs 0 01.08.2013 00:12
axaptapedia: Job Template (for running database maintenance script etc) Blog bot DAX Blogs 5 17.03.2010 09:11

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:12.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.