Azure Files share doesn't Work - powershell

I've trying to create a share in Azure Files, but doesn't seem to work. I'm aware I have to create a new storage account, because it won't work with existing ones. So I have just deleted my empty storage account and re-created it.
Then I'm following the guide using Windows Azure PowerShell, but it gives the following error:
The remote name could not be resolved: 'storageaccountname.file.core.windows.net'
Note that I've replaced my storage account name with 'storageaccountname' and the key with 'storageaccountkey'.
PS C:\System\AzureStorageFile> import-module .\AzureStorageFile.psd1
VERBOSE: Loading module from path 'C:\System\AzureStorageFile\AzureStorageFile.psd1'.
VERBOSE: Loading 'TypesToProcess' from path 'C:\System\AzureStorageFile\Microsoft.WindowsAzure.Commands.Storage.File.types.ps1xml'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\System\AzureStorageFile\Microsoft.WindowsAzure.Commands.Storage.File.format.ps1xml'.
VERBOSE: Loading module from path 'C:\System\AzureStorageFile\Microsoft.WindowsAzure.Commands.Storage.File.dll'.
VERBOSE: Importing cmdlet 'Get-AzureStorageFile'.
VERBOSE: Importing cmdlet 'Remove-AzureStorageFile'.
VERBOSE: Importing cmdlet 'Set-AzureStorageFileContent'.
VERBOSE: Importing cmdlet 'Get-AzureStorageFileContent'.
VERBOSE: Importing cmdlet 'Get-AzureStorageShare'.
VERBOSE: Importing cmdlet 'New-AzureStorageDirectory'.
VERBOSE: Importing cmdlet 'New-AzureStorageShare'.
VERBOSE: Importing cmdlet 'Remove-AzureStorageDirectory'.
VERBOSE: Importing cmdlet 'Remove-AzureStorageShare'.
VERBOSE: Importing cmdlet 'New-AzureStorageContext'.
VERBOSE: Exporting cmdlet 'Get-AzureStorageFile'.
VERBOSE: Exporting cmdlet 'Remove-AzureStorageFile'.
VERBOSE: Exporting cmdlet 'Set-AzureStorageFileContent'.
VERBOSE: Exporting cmdlet 'Get-AzureStorageFileContent'.
VERBOSE: Exporting cmdlet 'Get-AzureStorageShare'.
VERBOSE: Exporting cmdlet 'New-AzureStorageDirectory'.
VERBOSE: Exporting cmdlet 'New-AzureStorageShare'.
VERBOSE: Exporting cmdlet 'Remove-AzureStorageDirectory'.
VERBOSE: Exporting cmdlet 'Remove-AzureStorageShare'.
VERBOSE: Exporting cmdlet 'New-AzureStorageContext'.
VERBOSE: Importing cmdlet 'Get-AzureStorageFile'.
VERBOSE: Importing cmdlet 'Get-AzureStorageFileContent'.
VERBOSE: Importing cmdlet 'Get-AzureStorageShare'.
VERBOSE: Importing cmdlet 'New-AzureStorageContext'.
VERBOSE: Importing cmdlet 'New-AzureStorageDirectory'.
VERBOSE: Importing cmdlet 'New-AzureStorageShare'.
VERBOSE: Importing cmdlet 'Remove-AzureStorageDirectory'.
VERBOSE: Importing cmdlet 'Remove-AzureStorageFile'.
VERBOSE: Importing cmdlet 'Remove-AzureStorageShare'.
VERBOSE: Importing cmdlet 'Set-AzureStorageFileContent'.
PS C:\System\AzureStorageFile> $ctx = New-AzureStorageContext storageaccountname storageaccountkey
PS C:\System\AzureStorageFile> $s = New-AzureStorageShare data -Context $ctx
New-AzureStorageShare : The remote name could not be resolved: 'storageaccountname.file.core.windows.net'
At line:1 char:6
+ $s = New-AzureStorageShare data -Context $ctx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Windo...ureStorageShare:NewAzureStorageShare) [New-AzureStorageShare], StorageException
+ FullyQualifiedErrorId : NameResolutionFailure,Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet.NewAzureStorageShare

Azure Files is still in preview mode and is not automatically enabled. Follow the steps at http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx. The first step asks you to go to http://www.windowsazure.com/en-us/services/preview/ to sign up for the Azure Files Preview feature. Once you sign up for the preview you will have to wait until you get an email letting you know you are approved for the feature.

Is your storage account name you are using “'storageaccountname”? If so, and you just created the storage account, then it appears the subscription you are using hasn’t been approved for the preview yet, which will result in the 'storageaccountname.file.core.windows.net' not resolving.
If you need access then follow the instructions here:
http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx
Note, we are slowly opening up access, so based on the very high demand the wait may be awhile. You will receive email once your access is approved. Thanks.

Stupid question, but did you try already with creating a new one with a different name?

Related

Windows 10 SSH server installation does not create required services

I am trying to install Open-SSH on my Windows 10 pc in order to connect to it from my linux machine with ssh. I am following this tutorial, but as soon as I have to run something like Start-Service ssh-agent, it says that the service doesn't exist. Another thing that doesn't work is Install-Module -Force OpenSSHUtils, and it says that the signature of the file 'OpenSSHUtils.psd1' is not valid. I have tried many other tutorials, uninstalling everything before each one, and none of them are working. Is there any way to install these things manually? Am I missing an important step of the installation?
You do know you can install SSH directly in Windows 10 by using Add Feature option, correct? No need to download an external module/tool unless the builtin one does not provide all you are after.
Installation of OpenSSH For Windows Server 2019 and Windows 10
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Using the GUI
How to Enable and Use Windows 10’s New Built-in SSH Commands
Yet, if you do decide to use external stuff, then, Always test destructive (CUD = Create, Update, delete) code before true implementation.
Find-Module -Name 'OpenSSHUtils' -Verbose
<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
Version Name Repository Description
------- ---- ---------- -----------
1.0.0.1 OpenSSHUtils PSGallery Configure OpenSSH for Windows related security settings like file owner and permissions.
#>
Find-Module -Name 'OpenSSHUtils' -Verbose |
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules" -Verbose -WhatIf
<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Save Package" on target "'OpenSSHUtils' to location 'C:\Users\Daniel\Documents\WindowsPowerShell\Modules'".
#>
Install-Module -Name 'OpenSSHUtils' -Verbose -WhatIf
<#
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Install-Module" on target "Version '1.0.0.1' of module 'OpenSSHUtils'".
#>

Publish-PSArtifactUtility cannot resolve module dependency when publishing even when they are in the same feed

I'm trying to publish a PowerShell module to Azure Artifacts which has a dependency on another module that is hosted in the same Artifacts feed. The idea is that when I install the module locally from the feed, the correct version of the dependency is installed automatically. The problem is that when I run:
Publish-Module -NuGetApiKey "{token}" -Path {path} -Repository "{ArtifactsFeedName}" -Verbose -ErrorAction Stop
I get the following error:
Publish-PSArtifactUtility : PowerShellGet cannot resolve the module dependency '{dependency}' of the module
'{moduleWhichHasDependency}' on the repository '{ArtifactsFeed}'. Verify that the dependent module '{dependency}'
is available in the repository '{ArtifactsFeed}'. If this dependent module '{dependency}' is managed externally,
add it to the ExternalModuleDependencies entry in the PSData section of the module manifest.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1190 char:17
+ Publish-PSArtifactUtility -PSModuleInfo $moduleInfo `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Publish-PSArtifactUtility], InvalidOperationException
+ FullyQualifiedErrorId : UnableToResolveModuleDependency,Publish-PSArtifactUtility
In the manifest, the dependency is added like this:
RequiredModules = #( #{ModuleName = '{dependency}'; ModuleVersion = '1.0.4'; })
Then I tried adding:
ExternalModuleDependencies = #( #{ModuleName = '{dependency}'; ModuleVersion = '1.0.4'; })
The module is published but when I install it locally, it doesn't install the dependency.
This issue seems to have been fixed in the latest version of PowershellGet (2.2 in the PSGallery, version installed on my computer was 1.0.1).
You could also install the latest version of PackageManagement (1.4.3 vs 1.0.1)
See :
Added credential parameter to subsequent calls of Publish-Module/Script. #93
https://github.com/PowerShell/PowerShellGet/pull/93
Implement Publish-Module credential parameter propagation to sub-functions #104
https://github.com/PowerShell/PowerShellGet/pull/104
To do this :
Install-Module PowershellGet -Force #-Scope Current #if you don't want to login as Administrator
However, I have a question for you : how do you manage not to give your Credentials when you call Publish-Module with an Azure Artifact feed ? I know they should be stored in the file nuget.config but I have to give them each time.
Publish-Module -NuGetApiKey "{whatever}" -Credentials "{PSCredentials object}" -Path {path} -Repository "{ArtifactsFeedName}" -Verbose -ErrorAction Stop
expanding on #clientGOOG answer, my version was 2.2.4.1 but i had the same issue, i am publishing to myget and i solved this problem by using a pre-authenticated thread. I did not have to add ExternalModuleDependencies settings to make this work.
With the -Verbose flag I noticed that the "find" process was retrying 3x before giving up.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : '{myrepo}'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://{myorg}.myget.org/F/{myfeed}/api/v3/index.json' and PackageManagementProvider is 'NuGet'.
VERBOSE: Retry downloading 'https://{myorg}.myget.org/F/{myfeed}/api/v3/index.json' for '2' more times
VERBOSE: Retry downloading 'https://{myorg}.myget.org/F/{myfeed}/api/v3/index.json' for '1' more times
VERBOSE: Retry downloading 'https://{myorg}.myget.org/F/{myfeed}/api/v3/index.json' for '0' more times
VERBOSE: Total package yield:'0' for the specified package '{dependent module}'.
Here is my revised code that solved the issue:
Register-PSRepository -Name {MyRepo} "https://{myorg}.myget.org/F/{myfeed}/auth/{apikey}/api/v2"
Publish-Module -Path ($module.path |Split-Path -Parent) -NuGetApiKey $APIKey -Repository {MyRepo} -Verbose -ErrorAction Stop
Note: it still required the NuGetApiKey on the publish but the authenticated feed i would assume is passed down to the "find" call that is failing which is why it now works.

Powershell Binary Module not found but installed

I've created a Binary Powershell Module called ODBCManager. After installing from a feed, I am able to use it's functions successfully, but Get-Module does not find it by name (Get-Module -Name ODBCManager returns null). Get-Module -ListAvailable will show it after a 2 minute query, so it's definitely installed. Also -Verbose on installation says success.
C:\Users\xxxxx> Get-Module -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Binary 0.1.0.1 ODBCManager {Add-OracleODBC, Get-ODBCDrivers, New-OracleODBC}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script 3.4.0 Pester {Describe, Context, It, Should...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove-PSReadlineKeyHandler, Get-PSReadlineOption...}
Manifest 20.0 SqlServer {Add-SqlColumnEncryptionKeyValue, Complete-SqlColumnMasterKeyRotation, Get-SqlColumnEncryptionKey, Get-SqlColumnMasterKey...}
Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 ActiveDirectory {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-ADDomainControllerPasswordReplicationPolicy, Add-ADFineGrainedPasswordPolicySu... Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnosticLog, Set-AppBackgroundTaskResourcePolicy, Unregister-AppBackgroundTask...} Manifest 2.0.0.0 AppLocker {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPolicy, Set-AppLockerPolicy...}
Manifest 1.0.0.0 AppvClient {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add-AppvPublishingServer, Disable-Appv...}
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage...}
Script 1.0.0.0 AssignedAccess {Clear-AssignedAccess, Get-AssignedAccess, Set-AssignedAccess}
Manifest 1.0 BestPractices {Get-BpaModel, Get-BpaResult, Invoke-BpaModel, Set-BpaResult}
......................
Directory: C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0 SQLASCMDLETS {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}
Manifest 1.0 SQLPS {Backup-SqlDatabase, Add-SqlAvailabilityDatabase, Add-SqlAvailabilityGroupListenerStaticIp, Disable-SqlAlwaysOn...}
Directory: C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 2.0 SQLASCMDLETS {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}
Manifest 1.0 SQLPS {Add-SqlColumnEncryptionKeyValue, Complete-SqlColumnMasterKeyRotation, Get-SqlColumnEncryptionKey, Get-SqlColumnMasterKey...}
C:\Users\xxxxxx> Install-Module -Name ODBCManager -Scope AllUsers -Force -ErrorAction Stop -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '2' more times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '1' more times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '0' more times
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Total package yield:'0' for the specified package 'ODBCManager'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'http://srv-proget/nuget/QASolutions-PS/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'http://srv-proget/nuget/QASolutions-PS/FindPackagesById()?id='ODBCManager'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'ODBCManager'.
VERBOSE: Performing the operation "Install-Module" on target "Version '0.1.0.1' of module 'ODBCManager'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'ODBCManager' with version '0.1.0.1' from the repository 'http://srv-proget/nuget/QASolutions-PS/'.
VERBOSE: Searching repository 'http://srv-proget/nuget/QASolutions-PS/FindPackagesById()?id='ODBCManager'' for ''.
VERBOSE: InstallPackage' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxxx\AppData\Local\Temp\191916'
VERBOSE: DownloadPackage' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxx\AppData\Local\Temp\191916\ODBCManager\ODBCManager.nupkg',
uri='http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'
VERBOSE: Downloading 'http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'.
VERBOSE: Completed downloading 'http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'.
VERBOSE: Completed downloading 'ODBCManager'.
VERBOSE: Hash for package 'ODBCManager' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxx\AppData\Local\Temp\191916'
VERBOSE: Catalog file 'ODBCManager.cat' is not found in the contents of the module 'ODBCManager' being installed.
VERBOSE: For publisher validation, current module 'ODBCManager' with version '0.1.0.1' with publisher name ''. Is this module signed by Microsoft: 'False'.
VERBOSE: For publisher validation, using the previously-installed module 'ODBCManager' with version '0.1.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\ODBCManager\0.1.0.1' with publisher name ''. Is this module signed by Microsoft: 'False'.
VERBOSE: Module 'ODBCManager' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\ODBCManager\0.1.0.1'.
I have it hosted in ProGet under a Powershell Modules Feed
On Publish, folder name and DLL name are the same
Manifest has been created
Functions export and execute as expected
Manifest:
#{
RootModule = 'ODBCManager.dll'
ModuleVersion = '0.1.0.1' # filled in by cake-build process
CmdletsToExport = '*'
GUID = 'xxx-xxx-xxx-xx-xx'
DotNetFrameworkVersion = '4.0'
Author = 'xxx'
Description = 'PowerShell Binary Module for manipulating ODBCs.'
CompanyName = 'xxx'
Copyright = '(c) 2017 xxx. All rights reserved.'
PrivateData = #{
PSData = #{
ProjectUri = 'xxxxxxxxxx'
LicenseUri = ''
ReleaseNotes = 'First Release'
}
}
}
Have I forgot something? Because I've tried everything.
EDIT: After help from #BenH I was able to research further and found you can call Get-Module -ListAvailable -Name ODBCManager to quickly show your module installed, but not imported. -- For future reference!
Install-Module and Import-Module are different. Get-Module returns all of the Modules that are imported and Get-Module -ListAvailable returns all of the modules that are installed.
Thus your module is "Installed" but not "Imported".
With later versions of PowerShell, modules are dynamically imported if their functions/cmdlets are defined in the exported functions/cmdlets of the .psd1. But until they are imported, Get-Module will not list them.
Try this:
Import-Module ODBCManager
Get-Module ODBCManager

WMF 5.0(RTM) DSC resource not being installed propery

After upgrading to WMF 5.0 DSC seems to be having problems installing my custom class based resource module.
PS C:\Users\alexis.coles.adm> Start-DscConfiguration -ComputerName ComputerName -Credential $autoCred -Path E:\DevResetRuntime\Mofs -Wait -Verbose -Force
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Micr
osoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer ComputerName with user sid S-1-5-21-xxxxxxxxx-3810362189-311025990-3170.
VERBOSE: [ComputerName]: LCM: [ Start Set ]
VERBOSE: [ComputerName]: [DSCEngine] Module SxDeployment_1.11.zip downloaded.
VERBOSE: [ComputerName]: [DSCEngine] Resource SxDeployment version 1.11 installed.
VERBOSE: [ComputerName]: LCM: [ End Set ]
The PowerShell DSC resource C:\Program Files\WindowsPowerShell\Modules\SxDeployment\1.11\DscResources\PsPackageProvider does not contain the corresponding MOF file C:\Program
Files\WindowsPowerShell\Modules\SxDeployment\1.11\DscResources\PsPackageProvider\PsPackageProvider.schema.mof. Could not install module dependencies needed by the configuration.
+ CategoryInfo : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : ProviderSchemaFileNotFound
+ PSComputerName : ComputerName
If I run this on a box that has not been upgraded it installs fine and the module is downloaded from the Resource Module Manager and extracted to the correct location.
However running this on an upgraded box only creates an empty SxDeployment folder in C:\program files\windowsPowershell\Modules.
If I copy the good extracted folder from an un-upgraded box to the new box the configuration runs fine.
Any ideas?
UPDATE
My resource zip file is named SxDeployment_1.27.zip
It just contains the following 2 files
SxDeployment.psd1
SxDeployment.psm1
I am expecting this to get extracted to the following files system structure:
Modules
SxDeployment
1.27
SxDeployment.psd1
SxDeployment.psm1
However all I get is
Modules
SxDeployment

PowerShell change printer configuration from Administration tab

Im able to create and install printers using powershell. Now i also need to automate the printer configuration and need to change multiple values in the Administration tab.
How can i do that via powershell? I tried Set-PrinterProperty but i can't get it to work.
Thanks
One way I found easy to implement this was to start from current printer configuration, using Get-PrinterConiguration, then look at the xml and change whatever you need to, then use Set-PrinterProperty to push up the new xml.
Below is a function I created a while ago to update Printer Tray. It should (hopefully) get you started.
Function Set-MyDefaultPrinterTray {
#Requires -module PrintManagement
<#
.SYNOPSIS
Update Default Tray assignment of printer
.EXAMPLE
> Set-MyDefaultPrinterTray -ComputerName (Get-Content C:\temp\epicprinter\servers.txt) -PrintQueue ZZZ_Adil_Test03 -Tray 4 -Verbose
VERBOSE: Change tray to Tray4 on epswcdcqvm001
VERBOSE: Getting PrintConfiguration...
VERBOSE: epswcdcqvm001 : CurrentTray is psk:AutoSelect
VERBOSE: epswcdcqvm001 : New Tray ns0000:Tray4
VERBOSE: Performing the operation "Update Tray" on target "epswcdcqvm001".
VERBOSE: epswcdcqvm001 : Setting new tray assignment
VERBOSE: epswcdcqvm001 : Adding to success table
VERBOSE: Change tray to Tray4 on epswcdcqvm002
VERBOSE: Getting PrintConfiguration...
VERBOSE: epswcdcqvm002 : CurrentTray is psk:AutoSelect
VERBOSE: epswcdcqvm002 : New Tray ns0000:Tray4
VERBOSE: Performing the operation "Update Tray" on target "epswcdcqvm002".
VERBOSE: epswcdcqvm002 : Setting new tray assignment
VERBOSE: epswcdcqvm002 : Adding to success table
VERBOSE: Change tray to Tray4 on epswcdcqvm001
VERBOSE: Getting PrintConfiguration...
VERBOSE: epswcdcqvm001 : CurrentTray is ns0000:Tray4
VERBOSE: epswcdcqvm001 : New Tray ns0000:Tray4
VERBOSE: Performing the operation "Update Tray" on target "epswcdcqvm001".
VERBOSE: epswcdcqvm001 : Setting new tray assignment
Name Value
---- -----
epswcdcqvm002 Succeed
epswcdcqvm001 Succeed
.EXAMPLE
D:\> Set-MyDefaultPrinterTray -PrintServer 'epswcdcqvm001','epswcdcqvm002' -PrintQueue ZZZ_Adil_Test03 -Tray Tray2 -Verbose
VERBOSE: Change tray to Tray2 on epswcdcqvm001
VERBOSE: Getting PrintConfiguration...
VERBOSE: epswcdcqvm001 : CurrentTray is psk:AutoSelect
VERBOSE: epswcdcqvm001 : New Tray ns0000:Tray2
VERBOSE: Performing the operation "Set-EpicDefaultPrinterTray" on target "epswcdcqvm001".
VERBOSE: epswcdcqvm001 : Setting new tray assignment
VERBOSE: Change tray to Tray2 on epswcdcqvm002
VERBOSE: Getting PrintConfiguration...
VERBOSE: epswcdcqvm002 : CurrentTray is psk:AutoSelect
VERBOSE: epswcdcqvm002 : New Tray ns0000:Tray2
VERBOSE: Performing the operation "Set-EpicDefaultPrinterTray" on target "epswcdcqvm002".
VERBOSE: epswcdcqvm002 : Setting new tray assignment
#>
[CMDLETBINDING(SupportsShouldProcess)]
param(
[Parameter(Mandatory,ValueFromPipeline,Position=0)]
[Alias('PrintServer')]
[string[]]$ComputerName,
#[string[]]$PrintServer,
[Parameter(Mandatory,Position=1)]
[string]$PrintQueue,
[ValidateSet('1','2','3','4','Tray1','Tray2','Tray3','Tray4','AutoSelect','ManualFeed')]
$Tray='AutoSelect'
)
BEGIN
{
switch ($tray)
{
1 {$tray='Tray1';break}
2 {$tray='Tray2';break}
3 {$tray='Tray3';break}
4 {$tray='Tray4';break}
}
$result = #{}
}
PROCESS
{
Foreach ($ps in $ComputerName)
{
Write-Verbose "Change tray to $tray on $ps"
try
{
if (! (Test-Connection -ComputerName $ps -Count 1 -Quiet)) {
throw "Not Pingable"
}
Write-Verbose "Getting PrintConfiguration..."
$PrintConfiguration = Get-PrintConfiguration -ComputerName $ps -PrinterName $PrintQueue
$PrintTicketXML = [xml]$PrintConfiguration.PrintTicketXML
$currentTray = ($PrintTicketXML.PrintTicket.Feature).where({$_.name -eq 'psk:JobInputBin'}).option.name
Write-Verbose "$ps : CurrentTray is $currentTray "
if ($Tray -eq 'AutoSelect') {
$NewTray= "psk:$Tray"
} else {
$NewTray= "ns0000:$Tray"
}
Write-Verbose "$ps : New Tray $NewTray "
$UpdatedPrintTicketXML = $PrintConfiguration.PrintTicketXML -replace "$currentTray","$NewTray"
if ($PSCmdlet.ShouldProcess($ps,"Update Tray") ) {
Write-Verbose "$ps : Setting new tray assignment"
Set-PrintConfiguration -ComputerName $ps -printername $PrintQueue -PrintTicketXml $UpdatedPrintTicketXML
if (!$result.ContainsKey($ps)) {
Write-Verbose "$ps : Adding to success table"
$result.Add($ps,'Succeed')
}
}
}
catch
{
if (!$result.ContainsKey($ps)) {
Write-Verbose "$ps : Adding to fail table"
$result.Add($ps,'Fail')
}
Write-Error $error[0].exception
}
}
}
END
{
$result
}
}
Best way to do this is to use the below Windows tool, it should, but of course it isn't guaranteed, work with the "Administration tab".
Rundll32 printui.dll,PrintUIEntry
The way this tool works is, you firstly set the printer with the settings you want (configure your Administration tab accordingly) and export the settings to a file with a command like this (in CMD or PowerShell):
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n "PRINTER_NAME" /a "C:\printerSettings.dat" g d u
At "PRINTER_NAME" you enter your desired printer name (with quotation marks) and at "C:..." the location where the settings file should be saved. The parameters at the end here aren't necessarily, with the you specify what gets saved to the file, without any parameters everything gets saved and that might be best here...
Now, your settings are saved in a file, you'll then use that file for restoring settings on other printers with the same drivers with something like this:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n "PRINTER_NAME" /a "C:\printerSettings.dat" g d u p i r
The difference as you might noticed are the commands "/Ss" for saving and "/Sr" for restoring and different parameters at the end. Here a bit tricky thing to notice - if you run this with administration rights the above code should work fine, but otherwise you'll get a error. The problem is "g" parameter here, as it tries to change/restore the default settings of the printer and not only the settings for the current user. The settings for the current user are restored with "u". So you will maybe need to remove the "g" parameter.
Other parameters are described at the link, the more important ones I'll copy here (this are for restoring - "/Sr" command):
r: If the printer name stored in the file is different from the name of the printer being restored to, then use the current printer name. This cannot be specified with f. If neither r nor f is specified and the names do not match, restoration of the settings fails.
f: If the printer name stored in the file is different from the name of the printer being restored to, then use the printer name in the file. This cannot be specified with r. If neither f nor r is specified and the names do not match, restoration of the settings fails.
i: If the driver in the saved settings file does not match the driver for the printer being restored to, then the restoration fails.
p: If the port name in the file being restored from does not match the current port name of the printer being restored to, the printer’s current port name is used.
d: Use to restore printer specific data, such as the printer’s hardware ID.