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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 17.01.2017, 08:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
waldo: PowerShellGet & waldo’s PowerShell Modules
Источник: https://dynamicsuser.net/nav/b/waldo...rshell-modules
==============

Since Microsoft Dynamics NAV 2017, the VM images that Microsoft (Freddy) makes available on Azure, contains the PowerShellGet module. Freddy mentioned that in one of his blogposts about the Azure images. For me this was quite new, but sounded interesting, so I looked into it.

What is “PowerShellGet”?

Well, PowerShellGet is a module that is now by default present on Windows 10 (and I assume also on Windows Server 2016 – which is by the way the new OS for all the upcoming demo environments!) that makes it much easier for you to find, download and install PowerShell modules that are made available in the PowerShell Gallery: https://www.powershellgallery.com/ . If PowerShellGet not available on your OS, you can download it from that web page.

So, when you installed the module, you get PowerShell CmdLets that can search for PowerShell modules, install them, load them, and make them available. So in a way, from within a script, you can make available PowerShell modules.

The thing really makes me think of the way we installed stuff on Linux many years ago, with the apt-get command.

I made my PowerShell modules available on the PowerShell Gallery

Which you might have expected – hence the title :-). You can find them easily when you search for “waldo” on the PowerShell Gallery. But that’s not really how you should use it. You have to use it from PowerShell (in my opinion).

Let’s show that in this small walkthrough

I just created myself an image of The NAV Development Tools Preview – January Update (oh yes, there is a new update on the New DEV tools! ). But as said, this should work on any Win10 or WinServer2016 – or any system where you installed the PowerShellGet module.

Just open PowerShell as an administrator (since you’re installing modules, it seems like a good idea to do that as admin…). Let’s first search for my modules from within PowerShell:

Find-Module | where Author -eq waldoThe “Find-Module” is part of the “PowerShellGet” module, which is going to search for modules in the gallery. So in this case, I will search of all my modules in the gallery.

So if we execute this:

Find-Module | where Author -eq waldo | Install-Modulewith the “install-module” (also part of the “PowerShellGet” module), it will “install all waldo’s modules :-)”. So when you get this:



You simply say “yes to all”, since you trust me (IF you trust me :-)). It will download and install the modules. You’ll find the downloaded files in “C:\Program Files\WindowsPowerShell\Modules”.

Since it will just have downloaded them, you need to still import them like you have to import any module before you can use them in your runspace .. So therefore:

Import-Module Cloud.Ready.Software.NAVWith this line, you can show all the functions that you have just made available by downloading the modules from the PowerShell Gallery.

get-command -Module Cloud.Ready.Software.*So, let’s see if it works

Ok, let’s try some of my functions on this Azure image.

In order to do that, we will first import the standard NAV commandlets. And I made that somewhat easier with this function:

Import-NAVModulesThis function will put all the commands that are necessary to load the default NAV CmdLets to your clipboard. Simply past and execute. I haven’t managed to import the module in the global context from within the function (seems like a bug in PowerShell) – but this did the trick quite nicely as well :-). So paste the content of the clipboard in the shell, and execute!

Now, let’s set up a new sandbox environment (database and NST) by simply copy everything from the “NAV” instance:

Get-NAVServerInstance -ServerInstance 'NAV' | Copy-NAVEnvironment -ToServerInstance sandboxAnd start the development environment:

Start-NAVIdeClient sandboxThis is how I always build my development environments on dev images – local or in the cloud. To remove, you can simply do:

Remove-NAVEnvironment -ServerInstance sandboxBe careful with that one. It’s removing the database and server instance – so be sure you have a backup when needed :-).

What if you have updated your modules?

Well, you can imagine there is a PowerShellGet function for that as well: Update-Module. You can simply do:

Find-Module | where author -eq waldo | Update-ModuleThis PowerShellGet-module is awesome! :-). Thanks, Freddy, for introducing me :-).




Источник: https://dynamicsuser.net/nav/b/waldo...rshell-modules
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
waldo: Merging NAV Versionlists to NAV 2017 – Updated PowerShell functions! Blog bot NAV: Blogs 0 24.10.2016 04:30
waldo: Microsoft Dynamics NAV 2017 – what’s really new? Blog bot NAV: Blogs 0 13.10.2016 05:22
waldo: Invoke-NAVSQL: Execute SQL queries on NAV databases with PowerShell Blog bot NAV: Blogs 0 08.06.2016 03:17
How to install Waldo’s PowerShell Modules Blog bot Dynamics CRM: Blogs 0 09.12.2015 03:01
Download Waldo’s PowerShell Modules Blog bot Dynamics CRM: Blogs 0 20.11.2015 12:58
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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