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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 01.08.2013, 00:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,477 / 846 (79) +++++++
Регистрация: 28.10.2006
PowerShell Script to Run As A Different User
Источник: http://alexvoy.blogspot.com/2013/07/...different.html
==============

Short script for PowerShell that allows you to start, for example, Dynamics AX client under a different user account.

The main idea is to store the user's password as a secured string in a file, then to restore it from there and create credentials to launch the program.

First, run the script to save the password:


Write-Host "Input password for USERNAME..."
read-host -assecurestring | convertfrom-securestring | out-file C:\Scripts\USERNAMEpwd.txt
The following script can be saved in a file like RunDynamicsAXasUSERNAME.ps1 to be run as you need:


#Alex Voytsekhovskiy 2013-07-29
# Based on the links:
# http://blogs.technet.com/b/robcost/a...edentials.aspx
# http://jdhitsolutions.com/blog/2012/...-pscredential/
###############################################################################################
# This script is to run Dynamics AX under a different user account
# Without user input for credentials
###############################################################################################
[String]$Username = 'DOMAIN\USERNAME'

# Please check the following paths
# Absolute path to Dynamics AX shortcut
[string]$DynamicsAXAbsolutePath = 'S:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe'

# Absolute path to the secured password file
[string]$PasswordAbsolutePath = 'C:\Scripts\USERNAMEpwd.txt'

# Get the secured password from the file
$password = get-content $PasswordAbsolutePath | convertto-securestring

# Create credentials for the program launch
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $Username,$password

# Launch the program
echo "Trying to launch AX 2012..."
start-Process -FilePath $DynamicsAXAbsolutePath -Credential $credentials
I used the following links to create this script: http://blogs.technet.com/b/robcost/a...edentials.aspx
http://jdhitsolutions.com/blog/2012/...-pscredential/


Источник: http://alexvoy.blogspot.com/2013/07/...different.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dax-lessons: How to handle SSRS reports which will take long time to run with the messages to the user [Dynamics AX 2012– preRunValidate() method] Blog bot DAX Blogs 0 22.05.2012 02:12
mscrmblog: This report requires a default or user-defined value for the report parameter ‘Parameter’. To run or subsribe to this report, you must provide a parameter value Blog bot Dynamics CRM: Blogs 1 09.12.2010 09:51
daxdilip: AIF read Error executing code: Insufficient memory to run script Blog bot DAX Blogs 0 03.10.2010 16:05
Ошибка бизнес-процесса Tarasov E Dynamics CRM: Разработка 9 18.02.2010 14:02
Kashperuk Ivan: Run AX as a different user from Windows Explorer Blog bot DAX Blogs 0 15.01.2010 02:09

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

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

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