{"id":8117,"date":"2014-11-14T06:00:00","date_gmt":"2014-11-14T14:00:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=8117"},"modified":"2014-11-18T09:50:44","modified_gmt":"2014-11-18T17:50:44","slug":"update-oneget-install-oneget-on-ps-3-0","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2014\/11\/14\/update-oneget-install-oneget-on-ps-3-0\/","title":{"rendered":"Update-OneGet: Install OneGet on PS 3.0+"},"content":{"rendered":"<p>One of the coolest new features in the <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=44070\">Windows PowerShell 5.0 preview<\/a> is the <b>OneGet<\/b> module. Windows PowerShell program manager, Dan Harman, describes OneGet as a &#8220;package manager manager,&#8221; but for most of us, it represents a simple, repeatable, and reliable way to install, update, and uninstall a variety of available programs from a variety of sources.<\/p>\n<p>For example, if you want to install MarkDownPad2, a very simple and highly regarded HTML mark-up (or down) editor, you run a command like this:<\/p>\n<blockquote><p><span style=\"font-family: Lucida Console; font-size: small;\">Find-Package MarkDown2 | Install-Package<\/span><\/p><\/blockquote>\n<p>Yes. It&#8217;s just that easy. Really. And, if you need to uninstall it.<\/p>\n<blockquote><p><span style=\"font-family: Lucida Console; font-size: small;\">Get-Package MarkDown2 | Uninstall-Package<\/span><\/p><\/blockquote>\n<p>There are two versions of OneGet floating around:<\/p>\n<ul>\n<li>The <b>official<\/b> version of the OneGet module is included in the Windows Management Framework 5.0.<\/li>\n<li>The <b>experimental<\/b> version of the OneGet module is <a href=\"https:\/\/github.com\/OneGet\/oneget\">an open-source project on GitHub<\/a> run by <a href=\"http:\/\/blogs.msdn.com\/b\/garretts\/\">Garrett Serack<\/a>, (<a href=\"https:\/\/twitter.com\/fearthecowboy\">@fearthecowboy<\/a>) a lead developer of open source projects at Microsoft.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>The official version of OneGet is now available only in the Windows PowerShell 5.0 preview, which supports Windows 8.1, Windows Server 2012 R2, and later. I don&#8217;t know if they plan to make the official version available for earlier versions of Windows or Windows PowerShell.<\/p>\n<p>But, according to Garrett, the experimental version is designed to work on Windows PowerShell 3.0 and later, which supports Windows 7 SP1, Windows Server 2008 SP2, Windows Server 2008 R2 SP1, and later.<\/p>\n<p>So, I wrote a little script, <b>Update-OneGet.ps1<\/b> (attached below) that downloads the latest <b>experimental<\/b> version of the OneGet module, unblocks it (so you can run it with the RemoteSigned execution policy), unzips it, and saves it in a directory that you specify.<\/p>\n<h2>The Warnings<\/h2>\n<p>Now, the predictable warnings. Caveat emptor, especially when the download is free.<\/p>\n<ul>\n<li>You shouldn&#8217;t run any unofficial software on a production system or on any system with sensitive data or guaranteed up-time.<\/li>\n<li>Before running any open-source code on any system, review the code and make sure that it&#8217;s safe, or consult people who can verify that it&#8217;s safe.<\/li>\n<li>By design, open-source code is a work in progress. The version that you download this morning might work a bit differently than the version that you download in the afternoon.<\/li>\n<\/ul>\n<p>And one less predictable one:<\/p>\n<ul>\n<li>Dan Harman mentioned in his talk that the official Uninstall-Package cmdlet might not completely uninstall a program. You might need to run an MSI to completely uninstall it.<\/li>\n<\/ul>\n<h2><\/h2>\n<h2>Get the Experimental OneGet<\/h2>\n<p>I wrote a little script that downloads, unblocks, unzips, and installs the <b>experimental<\/b> version of the OneGet module on your system. It&#8217;s designed to be run repeatedly (hence the <b>Update<\/b> verb), so it always deletes everything in the directory and installs a new copy.<\/p>\n<p>You can run it on Windows PowerShell 3.0 and later and you don&#8217;t need to have a GitHub user account. (If you have a GitHub account, you don&#8217;t need to log in, because the script doesn&#8217;t use it.)<\/p>\n<p>The script has a <b>Path<\/b> parameter that takes the path to a directory. Update-OneGet installs the module in that directory.<\/p>\n<p><span style=\"color: #ff0000;\">Caution:<\/span> Do not install the experimental version of OneGet in <span style=\"font-family: Lucida Console; font-size: small;\">$pshome\\Modules<\/span>. If you do, it might prevent you from installing, uninstalling or updating the official version of the module.<\/p>\n<p>To be safe, especially on systems that have both the official and experimental versions of the OneGet module, install the experimental version in a directory that will not be auto-loaded; that is, a directory that is not listed in your <span style=\"font-family: Lucida Console;\">$env:PSModulepath<\/span> variable. For example:<\/p>\n<blockquote><p><span style=\"font-family: Lucida Console; font-size: small;\">$home\\Documents\\Test\\OneGetExperimental<\/span><\/p><\/blockquote>\n<p>-or-<\/p>\n<blockquote><p><span style=\"font-family: Lucida Console; font-size: small;\">C:\\ps-test\\OneGetExperimental<\/span><\/p><\/blockquote>\n<p>If you do not and will not have the official version, and you want the module to import automatically, you can provide the path to your current-user module directory, such as your <span style=\"font-family: Lucida Console; font-size: small;\">$home\\Documents\\WindowsPowerShell\\Modules\\OneGetExperimental<\/span> directory.<\/p>\n<p>In case you&#8217;re wondering, the Path value doesn&#8217;t affect the module name.\u00a0The module name is actually determined by the name of the module manifest file, so both the official and experimental versions are\u00a0&#8220;OneGet&#8221; in Windows PowerShell.<\/p>\n<p>The script also has an <b>Import<\/b> switch parameter that imports the module into the session after it&#8217;s installed. It&#8217;s optional, of course.<\/p>\n<p>To get help for the script, use Get-Help with the path and file name of the script. For example:<\/p>\n<blockquote><p><span style=\"font-family: Lucida Console;\">Get-Help .\\Update-OneGet.ps1<\/span><\/p><\/blockquote>\n<h2><\/h2>\n<h2>Importing OneGet (the experimental version)<\/h2>\n<p>After you install the OneGet module, you need to import it.<\/p>\n<p>If you installed OneGet in your current-user modules directory, or any directory that is listed in <span style=\"font-family: Lucida Console; font-size: small;\">$env:PSModulePath<\/span>, Windows PowerShell imports it automatically when you use a cmdlet in the module, such as <strong>Find-Package<\/strong>, or use Get-Command or Get-Help on a module cmdlet without wildcards.<\/p>\n<p>If you installed the module in a different directory, you can import it by using the path to the OneGet module manifest. Here&#8217;s how:<\/p>\n<blockquote><p><span style=\"font-family: Lucida Console; font-size: small;\">Import-Module &lt;Path&gt;\\OneGet.psd1<\/span><\/p><\/blockquote>\n<p>If you are running Windows PowerShell 5.0 preview, you&#8217;ll have both the official and experimental versions of the module. When you have commands in your session with the same name, the commands that run are the ones added to the session last (most recently) For details, see <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/hh848304.aspx\">about_Command_Precedence<\/a>. And, because the modules have the same name, qualifying the cmdlet name with the module name (&lt;Module&gt;\\Cmdlet) doesn&#8217;t help.<\/p>\n<p>To avoid this confusion, when you want to use a command in the experimental version of the OneGet module, explicitly remove any accidentally auto-loaded versions of OneGet from the session and import the version that you want.<\/p>\n<blockquote>\n<pre>    <span style=\"color: #0000ff;\">function<\/span> <span style=\"color: #008080;\">Import-OneGetEx<\/span><span style=\"color: #000000;\">\r\n    {        \r\n        <\/span><span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"font-weight: bold; color: #0000ff;\">Get-Module<\/span><span style=\"color: #000000;\"> OneGet) { <\/span><span style=\"font-weight: bold; color: #0000ff;\">Remove-Module<\/span><span style=\"color: #000000;\"> OneGet }        \r\n        <\/span><span style=\"font-weight: bold; color: #0000ff;\">Import-Module<\/span><span style=\"color: #000000;\"> &lt;Path&gt;\\OneGet.psd1\r\n    }<\/span><\/pre>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<h2>About OneGet<\/h2>\n<p>Today, there is no official help for the cmdlets in the OneGet module, but the Microsoft writers are working hard on it, and it should be available soon, both for the official and experimental modules.<\/p>\n<p>In the meantime, I recommend Dan Harman&#8217;s terrific talk at the PowerShell Summit 2014 in Europe: <a href=\"https:\/\/www.youtube.com\/watch?v=xbsLrf2N750&amp;index=4&amp;list=PLfeA8kIs7Coehjg9cB6foPjBojLHYQGb_\">Dan Harman &#8211; PowerShell Repositories Unleashed<\/a>. In this talk, Dan introduces OneGet and its favorite child, <strong>PowerShellGet<\/strong>, and then delves into how to create a package provider that connects the OneGet framework to a particular package manager repositories.<\/p>\n<p>&nbsp;<\/p>\n<h2>Script: Update-OneGet.ps1<\/h2>\n<p>With special thanks to Windows PowerShell MVP <a href=\"http:\/\/www.dougfinke.com\/\">Doug Finke<\/a> (<a href=\"https:\/\/twitter.com\/dfinke\">@dfinke<\/a>) for reviewing the code.<\/p>\n<p>You can copy the Update-OneGet.ps1\u00a0script\u00a0code here or\u00a0download\u00a0<a href=\"http:\/\/www.sapien.com\/downloads#Sample%20Scripts\/Update-OneGet.ps1.zip\" target=\"_blank\">a ZIP file of the\u00a0Update-OneGet.ps1 script<\/a> from the\u00a0<a href=\"http:\/\/www.sapien.com\/downloads\" target=\"_blank\">SAPIEN Downloads<\/a> site.<\/p>\n<p>To download, sign in, in the left nav, click <strong>Sample Scripts<\/strong>,\u00a0click <strong>Update-OneGet.ps1.zip<\/strong>, and in the top right corner, click <strong>Download<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<pre><span style=\"color: #008000;\">&lt;#\r\n    .NOTES\r\n    ===========================================================================\r\n     Created with:     PowerShell Studio 2014, Version 4.1.74\r\n     Created on:       11\/10\/2014 4:06 PM     \r\n     Company:          SAPIEN Technologies, Inc.\r\n     Contact:          June Blender, juneb@sapien.com, @juneb_get_help\r\n     Filename:         Update-OneGet.ps1\r\n    ===========================================================================\r\n\r\n    .SYNOPSIS\r\n        Downloads, installs, and imports the latest OneGet module from GitHub.\r\n\r\n    .DESCRIPTION\r\n        Update-OneGet.ps1 downloads, installs, and (optionally) imports the\r\n        latest experimental version of the OneGet module from http:\/\/OneGet.org,\r\n        which is linked to the OneGet project in GitHub.\r\n\r\n        The script downloads the OneGet.zip file from OneGet.org and saves it in\r\n        your downloads folder, $home\\Downloads. It unblocks the file, unzips it,\r\n        and installs it in the directory specified by the Path parameter.\r\n\r\n        If you include the optional Import parameter, the script imports the module\r\n        into the current session.\r\n\r\n        After running the script, to import the experimental version of OneGet into \r\n        any session, use the following command:\r\n            Import-Module &lt;path&gt;\\OneGet.psd1\r\n\r\n        This script runs on Windows PowerShell 3.0 and later. \r\n    .PARAMETER  Path\r\n        Specifies a directory where the script installs the module. This parameter is\r\n        required. Enter the path to a directory. Do not include a .zip file name extension. \r\n\r\n        If the directory does not exist, the script creates it. If the directory exists, \r\n        the script deletes the directory contents before installing the module. This lets \r\n        you reuse the directory when updating.\r\n\r\n        To prevent errors, specify a subdirectory of your Documents directory or a test \r\n        directory.\r\n\r\n        CAUTION: Do not specify a path in $pshome\\Modules. Installing the experimental build\r\n                 of OneGet in this directory might prevent you from installing, uninstalling, \r\n                 or updating the official OneGet module from Microsoft.\r\n\r\n    .PARAMETER  Import\r\n        Imports the module into the current session after installing it. \r\n\r\n    .EXAMPLE\r\n        .\\Update-OneGet.ps1 -Path $home\\Documents\\Test\\OneGet\r\n        \r\n        This command installs the newest OneGet module in the $home\\Documents\\Test\\OneGet\r\n        directory. To import it: Import-Module $home\\Documents\\Test\\OneGet.psd1\r\n\r\n    .EXAMPLE\r\n        .\\Update-OneGet.ps1 -Path $home\\Documents\\Test\\OneGet -Import\r\n        \r\n        This command installs the newest OneGet module in the \r\n        $home\\Documents\\Test\\OneGet    directory and imports it into the\r\n        current session. \r\n\r\n    .EXAMPLE\r\n        .\\Update-OneGet.ps1 -Path $home\\Documents\\WindowsPowerShellModules\\OneGet\r\n\r\n        This command installs the newest OneGet module in the your current-user \r\n        Modules    directory. Windows PowerShell imports it automatically when you use a \r\n        command in the module, such as Find-Package.\r\n\r\n\r\n    .OUTPUTS\r\n        System.Management.Automation.PSCustomObject, System.Management.Automation.PSModuleInfo\r\n        If you use the Import parameter, Update-OneGet returns a module object. Otherwise, it\r\n        returns a custom object with the Path and LastWriteTime of the OneGet module manifest,\r\n        OneGet.psd1\r\n#&gt;<\/span>\r\n\r\n<span style=\"color: #008000;\">#Requires -Version 3<\/span>\r\n\r\n<span style=\"color: #0000ff;\">Param<\/span><span style=\"color: #000000;\">\r\n(\r\n    [<\/span><span style=\"color: #4682b4;\">Parameter<\/span><span style=\"color: #000000;\">(Mandatory <\/span><span style=\"color: #0000ff;\">=<\/span> <span style=\"color: #8b0000;\">$true<\/span><span style=\"color: #000000;\">)]\r\n    [<\/span><span style=\"color: #4682b4;\">ValidateScript<\/span><span style=\"color: #000000;\">({<\/span><span style=\"color: #8b0000;\">$_<\/span> <span style=\"color: #0000ff;\">-notlike<\/span> <span style=\"color: #ff0000;\">\"*.zip\"<\/span> <span style=\"color: #0000ff;\">-and<\/span> <span style=\"color: #8b0000;\">$_<\/span> <span style=\"color: #0000ff;\">-notlike<\/span> <span style=\"color: #ff0000;\">\"$pshome*\"<\/span> <span style=\"color: #0000ff;\">-and<\/span> <span style=\"color: #8b0000;\">$_<\/span> <span style=\"color: #0000ff;\">-notlike<\/span> <span style=\"color: #ff0000;\">\"*System32*\"<\/span><span style=\"color: #000000;\">})]\r\n    [<\/span><span style=\"color: #0000cd;\">System.String<\/span><span style=\"color: #000000;\">]\r\n    <\/span><span style=\"color: #8b0000;\">$Path<\/span><span style=\"color: #000000;\">,\r\n\r\n    [<\/span><span style=\"color: #4682b4;\">Parameter<\/span><span style=\"color: #000000;\">(Mandatory<\/span><span style=\"color: #0000ff;\">=<\/span><span style=\"color: #8b0000;\">$false<\/span><span style=\"color: #000000;\">)]\r\n    [<\/span><span style=\"color: #0000cd;\">Switch<\/span><span style=\"color: #000000;\">]\r\n    <\/span><span style=\"color: #8b0000;\">$Import<\/span><span style=\"color: #000000;\">\r\n)\r\n\r\n<\/span><span style=\"color: #008000;\">#***************************#<\/span>\r\n<span style=\"color: #008000;\">#  Helper Functions         #<\/span>\r\n<span style=\"color: #008000;\">#***************************#<\/span>\r\n\r\n<span style=\"color: #008000;\"># Use this function on systems that do not have<\/span>\r\n<span style=\"color: #008000;\"># the Extract-Archive cmdlet (PS 5.0)<\/span>\r\n<span style=\"color: #008000;\">#<\/span>\r\n<span style=\"color: #0000ff;\">function<\/span> <span style=\"color: #008080;\">Unzip-OneGetZip<\/span><span style=\"color: #000000;\">\r\n{\r\n    <\/span><span style=\"color: #8b0000;\">$shell<\/span> <span style=\"color: #0000ff;\">=<\/span> <span style=\"font-weight: bold; color: #0000ff;\">New-Object<\/span> <span style=\"color: #3399ff;\">-ComObject<\/span><span style=\"color: #000000;\"> shell.application\r\n    <\/span><span style=\"color: #8b0000;\">$zip<\/span> <span style=\"color: #0000ff;\">=<\/span> <span style=\"color: #8b0000;\">$shell<\/span><span style=\"color: #000000;\">.NameSpace(<\/span><span style=\"color: #ff0000;\">\"$home\\Downloads\\OneGet.zip\"<\/span><span style=\"color: #000000;\">)\r\n    <\/span><span style=\"color: #0000ff;\">foreach<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"color: #8b0000;\">$item<\/span> <span style=\"color: #0000ff;\">in<\/span> <span style=\"color: #8b0000;\">$zip<\/span><span style=\"color: #000000;\">.items())\r\n    {\r\n        <\/span><span style=\"color: #8b0000;\">$shell<\/span><span style=\"color: #000000;\">.Namespace(<\/span><span style=\"color: #8b0000;\">$script:Path<\/span><span style=\"color: #000000;\">).Copyhere(<\/span><span style=\"color: #8b0000;\">$item<\/span><span style=\"color: #000000;\">)\r\n    }\r\n}\r\n\r\n<\/span><span style=\"color: #008000;\">#***************************#<\/span>\r\n<span style=\"color: #008000;\">#         Main              #<\/span>\r\n<span style=\"color: #008000;\">#***************************#<\/span>\r\n<span style=\"color: #008000;\"># Remove current OneGet from session<\/span>\r\n<span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"font-weight: bold; color: #0000ff;\">Get-Module<\/span> <span style=\"color: #3399ff;\">-Name<\/span><span style=\"color: #000000;\"> OneGet) {<\/span><span style=\"font-weight: bold; color: #0000ff;\">Remove-Module<\/span><span style=\"color: #000000;\"> OneGet}\r\n\r\n<\/span><span style=\"color: #008000;\"># Create the $Path path<\/span>\r\n<span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"color: #0000ff;\">!<\/span><span style=\"color: #000000;\">(<\/span><span style=\"font-weight: bold; color: #0000ff;\">Test-Path<\/span> <span style=\"color: #8b0000;\">$Path<\/span><span style=\"color: #000000;\">))\r\n{\r\n    <\/span><span style=\"color: #0000ff;\">try<\/span><span style=\"color: #000000;\">\r\n    {\r\n        <\/span><span style=\"font-weight: bold; color: #0000ff;\">mkdir<\/span> <span style=\"color: #8b0000;\">$Path<\/span> <span style=\"color: #0000ff;\">|<\/span> <span style=\"font-weight: bold; color: #0000ff;\">Out-Null<\/span><span style=\"color: #000000;\">\r\n    }\r\n    <\/span><span style=\"color: #0000ff;\">catch<\/span><span style=\"color: #000000;\">\r\n    {\r\n        <\/span><span style=\"color: #0000ff;\">throw<\/span> <span style=\"color: #ff0000;\">\"Did not find and cannot create the $Path directory.\"<\/span><span style=\"color: #000000;\">\r\n    }\r\n}\r\n<\/span><span style=\"color: #0000ff;\">else<\/span><span style=\"color: #000000;\">\r\n{\r\n    <\/span><span style=\"font-weight: bold; color: #c00000;\">dir<\/span> <span style=\"color: #8b0000;\">$Path<\/span> <span style=\"color: #0000ff;\">|<\/span> <span style=\"font-weight: bold; color: #0000ff;\">Remove-Item<\/span> <span style=\"color: #3399ff;\">-Recurse<\/span><span style=\"color: #000000;\">\r\n}\r\n\r\n<\/span><span style=\"color: #008000;\">#Download the Zip file to $home\\Downloads<\/span>\r\n<span style=\"color: #0000ff;\">try<\/span><span style=\"color: #000000;\">\r\n{\r\n    <\/span><span style=\"font-weight: bold; color: #0000ff;\">Invoke-WebRequest<\/span> <span style=\"color: #3399ff;\">-Uri<\/span><span style=\"color: #000000;\"> http:\/\/oneget.org\/oneget.zip <\/span><span style=\"color: #3399ff;\">-OutFile<\/span> <span style=\"color: #8b0000;\">$home<\/span><span style=\"color: #000000;\">\\Downloads\\OneGet.zip\r\n}\r\n<\/span><span style=\"color: #0000ff;\">catch<\/span><span style=\"color: #000000;\">\r\n{\r\n    <\/span><span style=\"color: #0000ff;\">throw<\/span> <span style=\"color: #ff0000;\">\"Cannot download OneGet zip file from http:\/\/oneget.org\"<\/span><span style=\"color: #000000;\">\r\n}\r\n<\/span><span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"color: #0000ff;\">!<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #8b0000;\">$zip<\/span> <span style=\"color: #0000ff;\">=<\/span> <span style=\"font-weight: bold; color: #0000ff;\">Get-Item<\/span> <span style=\"color: #3399ff;\">-Path<\/span> <span style=\"color: #8b0000;\">$home<\/span><span style=\"color: #000000;\">\\Downloads\\OneGet.zip)) \r\n{\r\n    <\/span><span style=\"color: #0000ff;\">throw<\/span> <span style=\"color: #ff0000;\">\"Cannot find OneGet zip file in $home\\Downloads\"<\/span><span style=\"color: #000000;\">\r\n}\r\n<\/span><span style=\"color: #0000ff;\">else<\/span><span style=\"color: #000000;\">\r\n{\r\n    <\/span><span style=\"color: #8b0000;\">$zip<\/span> <span style=\"color: #0000ff;\">|<\/span> <span style=\"font-weight: bold; color: #0000ff;\">Unblock-File<\/span>\r\n    <span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"font-weight: bold; color: #0000ff;\">Get-Command<\/span><span style=\"color: #000000;\"> Expand-Archive <\/span><span style=\"color: #3399ff;\">-ErrorAction<\/span><span style=\"color: #000000;\"> SilentlyContinue)\r\n    {\r\n        <\/span><span style=\"color: #8b0000;\">$zip<\/span> <span style=\"color: #0000ff;\">|<\/span> <span style=\"color: #696969;\">Expand-Archive<\/span> <span style=\"color: #0000ff;\">-<\/span><span style=\"color: #000000;\">DestinationPath <\/span><span style=\"color: #8b0000;\">$Path<\/span><span style=\"color: #000000;\">\r\n    }\r\n    <\/span><span style=\"color: #0000ff;\">else<\/span><span style=\"color: #000000;\">\r\n    {\r\n        <\/span><span style=\"color: #008080;\">Unzip-OneGetZip<\/span><span style=\"color: #000000;\">        \r\n    }    \r\n    \r\n    <\/span><span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"color: #0000ff;\">!<\/span><span style=\"color: #000000;\">(<\/span><span style=\"font-weight: bold; color: #0000ff;\">Test-Path<\/span> <span style=\"color: #8b0000;\">$Path<\/span><span style=\"color: #000000;\">\\OneGet.psd1))\r\n    {\r\n        <\/span><span style=\"color: #0000ff;\">throw<\/span> <span style=\"color: #ff0000;\">\"Cannot find OneGet.psd1 in $Path\"<\/span><span style=\"color: #000000;\">\r\n    }\r\n\r\n    <\/span><span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"color: #8b0000;\">$Import<\/span><span style=\"color: #000000;\">)\r\n    {        \r\n        <\/span><span style=\"font-weight: bold; color: #0000ff;\">Import-Module<\/span> <span style=\"color: #8b0000;\">$Path<\/span><span style=\"color: #000000;\">\\OneGet.psd1\r\n        <\/span><span style=\"color: #0000ff;\">if<\/span><span style=\"color: #000000;\"> ((<\/span><span style=\"font-weight: bold; color: #0000ff;\">Get-Module<\/span><span style=\"color: #000000;\"> OneGet).ModuleBase <\/span><span style=\"color: #0000ff;\">-ne<\/span> <span style=\"color: #8b0000;\">$Path<\/span><span style=\"color: #000000;\">)\r\n        {\r\n            <\/span><span style=\"color: #0000ff;\">throw<\/span> <span style=\"color: #ff0000;\">\"Failed to import the new OneGet module from $Path.\"<\/span><span style=\"color: #000000;\">\r\n        }\r\n        <\/span><span style=\"color: #0000ff;\">else<\/span><span style=\"color: #000000;\">\r\n        {\r\n            <\/span><span style=\"font-weight: bold; color: #0000ff;\">Get-Module<\/span><span style=\"color: #000000;\"> OneGet\r\n        }\r\n\r\n    }        \r\n    <\/span><span style=\"color: #0000ff;\">else<\/span><span style=\"color: #000000;\">\r\n    {\r\n        [<\/span><span style=\"color: #0000cd;\">PSCustomObject<\/span><span style=\"color: #000000;\">]@{Path <\/span><span style=\"color: #0000ff;\">=<\/span> <span style=\"color: #ff0000;\">\"$Path\\OneGet.psd1\"<\/span><span style=\"color: #000000;\">; Date <\/span><span style=\"color: #0000ff;\">=<\/span><span style=\"color: #000000;\"> (<\/span><span style=\"font-weight: bold; color: #c00000;\">dir<\/span> <span style=\"color: #8b0000;\">$Path<\/span><span style=\"color: #000000;\">\\OneGet.psd1).LastWriteTime}\r\n    }\r\n}<\/span><\/pre>\n<p><i>June Blender is a technology evangelist at SAPIEN Technologies, Inc. You can reach her at <a href=\"mailto:juneb@sapien.com\">juneb@sapien.com<\/a> or follow her on Twitter at <a href=\"https:\/\/twitter.com\/juneb_get_help\">@juneb_get_help<\/a>.<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the coolest new features in the Windows PowerShell 5.0 preview is the OneGet module. Windows PowerShell program manager, Dan Harman, describes OneGet as a &#8220;package manager manager,&#8221; but for most of us, it represents a simple, repeatable, and reliable way to install, update, and uninstall a variety of available programs from a variety [&hellip;]<\/p>\n","protected":false},"author":31,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[932,25],"tags":[934,28],"class_list":["post-8117","post","type-post","status-publish","format-standard","hentry","category-beginners","category-windows-powershell","tag-juneb","tag-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/8117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=8117"}],"version-history":[{"count":4,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/8117\/revisions"}],"predecessor-version":[{"id":8123,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/8117\/revisions\/8123"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=8117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=8117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=8117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}