PowerShell change printer configuration from Administration tab - powershell

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.

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'".
#>

Update Windows security remotely using powershell scheduled task

I am trying to Install windows security patches on a remote machine using powershell remoting.
This is the function i am using to Update windows
<#
.SYNOPSIS
This functiion will automatically install all avaialable windows updates on a device and will automatically reboot if needed, after reboot, windows updates will continue to run until no more updates are available.
#>
function Install-WindowsUpdates
{
Install-Module -Name PSWindowsUpdate -RequiredVersion 2.1.0.1 -Force
Import-Module PSWindowsUpdate -Force
Get-WindowsUpdate -install -acceptall
}
When i run this function on a local host, the function is successful in installing windows security patches. I have the below script to do the same remotely:
param(
[Parameter(Mandatory = $true)]
[string] $IPaddress
)
try
{
$secpasswd = ConvertTo-SecureString "Pass#12345678" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("Admin02", $secpasswd)
#Create a Session.
$Session = New-PSSession -ComputerName $IPaddress -Credential $cred
cd C:\Users\Admin01\Documents
. .\Install-WindowsUpdates.ps1
Invoke-Command -Session $Session -ScriptBlock ${function:Install-WindowsUpdates}
return $true
}
catch
{
return $false
}
When i run this script i am getting the below error:
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
+ CategoryInfo : NotSpecified: (:) [Get-WindowsUpdate], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,PSWindowsUpdate.GetWindowsUpdate
+ PSComputerName : 10.0.0.7
I have setup both the loaclhost and remote machine for remoting and able to execute other scripts remotely. Also have enabled WMI on the remote machine.
What other settings i have to do?
Using Scheduled Task:
I am using the following script to start a scheduled task:
param(
[parameter(Mandatory = $true)]
[string]$IPaddress
)
$PSModulePath = $env:PSModulePath
$SplittedModulePath = $PSModulePath.Split(";")
$ModulePath = $SplittedModulePath[0]
$secpasswd = ConvertTo-SecureString "Pass#12345678" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("Admin02", $secpasswd)
#Create a Session. Replace host name with the host name of the remote machine.
$Session = New-PSSession -ComputerName $IPaddress -Credential $cred
$User= "Admin02"
$Action= New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "$env:ALLUSERSPROFILE\Install-WindowsUpdate.ps1"
$Trigger= New-ScheduledTaskTrigger -At 5:05am -Once
Invoke-Command -Session $Session -ScriptBlock { Register-ScheduledTask -TaskName "Install-Updates" -User $Using:User -Action $Using:Action -Trigger $Using:Trigger -RunLevel Highest –Force }
I have copied the below script on the target machine at the path $env:ALLUSERSPROFILE
<#
.SYNOPSIS
This functiion will automatically install all avaialable windows updates on a device and will automatically reboot if needed, after reboot, windows updates will continue to run until no more updates are available.
.PARAMETER computer
Use the Computer parameter to specify the Computer to remotely install windows updates on.
#>
Install-Module -Name PSWindowsUpdate -RequiredVersion 2.1.0.1 -Force
Import-Module PSWindowsUpdate -Force
Get-WindowsUpdate -install -acceptall
After i schedule the task nothing is happening.What i am doing wrong?
Yea, I fought this for weeks and finally have a good solution. The solution is actually built right into the PSWindowsUpdate module. The built in solution does use a windows Task, but it launches right away, and its actually helpful in tracking its completion progress, and it keeps the integration secure. The issue I have found is that PSWindowsUpdate has poor documentation. The following code worked for me:
Invoke-WUJob -ComputerName $svr -Script {ipmo PSWindowsUpdate; Get-WUInstall -AcceptAll -AutoReboot -Install | Out-File C:\PSWindowsUpdate.log } -Confirm:$false -Verbose -RunNow
There is a lot of scattered information on this topic, so please do your reading. PSWindowsUpdate is by far the best library for this job, and although its been a long process for me, I believe the above solution will work for everyone.
Please remember, the computer you are running the above scrip from needs to trust the computer you are trying to update, you can run this script to trust the computer:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value <ComputerName>
NOTE: Wildcards can be used in computer name
I also wanted to give you some information that greatly helped me:
Get-WindowsUpdate: This is the main cmdlet of the module. It lists, downloads, installs or hides a list of updates meeting predefined requisites and sets the rules of the restarts when installing the updates.
Remove-WindowsUpdate: Uninstalls an update
Add-WUServiceManage: Registers a new Windows Update API Service Manager
Get-WUHistory: Shows a list of installed updates
Get-WUSettings: Gets Windows Update client settings
Get-WUInstallerStatus: Gets Windows Update Installer Status, whether it is busy or not
Enable-WURemoting: Enables firewall rules for PSWindowsUpdate remoting
Invoke-WUJob: Invokes PSWindowsUpdate actions remotely
Like for all PowerShell cmdlets, different usage examples can be shown for each command typing Get-Help “command” -examples.
PSWindowsUpdate main parameters
As shown in the previous section, the PSWindowsUpdate module includes different predefined aliases to ease patching processes. However, main parameters for the Get-WindowsUpdate cmdlet will be listed and explained below:
Filtering updates:
AcceptAll: Downloads or installs all available updates
KBArticleID: Finds updates that contain a KBArticleID (or sets of KBArticleIDs)
UpdateID: Specifies updates with a specific UUID (or sets of UUIDs)
Category: Specifies updates that contain a specified category name, such as ‘Updates,’ ‘Security Updates’ or ‘Critical Updates’
Title: Finds updates that match part of title
Severity: Finds updates that match part of severity, such as ‘Important,’ ‘Critical’ or ‘Moderate’
UpdateType: Finds updates with a specific type, such as ‘Driver’ and ‘Software.’ Default value contains all updates
Actions and targets:
Download: downloads approved updates but does not install them
Install: installs approved updates
Hide: hides specified updates to prevent them to being installed
ScheduleJob: specifies date when job will start
SendReport: sends a report from the installation process
ComputerName: specifies target server or computer
Client restart behavior:
AutoReboot: automatically reboots system if required
IgnoreReboot: suppresses automatic restarts
ScheduleReboot: specifies the date when the system will be rebooted.
#How to avoid accidental installs#
Windows updates and patches improve the features and stability of the system. However, some updates can mess up your system and cause instability, especially automatic updates for legacy software such as graphic card drivers. To avoid automatic updates and accidental installs for such applications, you can pause Windows updates.
Alternatively, you can hide the specific updates for those features you don’t want to get updated. When you hide the updates, Windows can no longer download and install such updates. Before you can hide the update, you need to find out its details, including its knowledge base (KB) number and title. Type the cmdlet below to list all the available updates on your system:
Get-WUList
To hide a specific update using the KB number, use your mouse to copy that KB number. Next, type the command below:
Hide-WUUpdate -KBArticleID KB_Number
Highlight the “KB_Number” and click paste to replace that part with the actual KB number.
When prompted to confirm the action, type A, and hit the Enter key. If the command succeeds, the “Get-WUList” lists all the available updates, with hidden updates appearing with the symbol “H” under their status.
The KB number for the update may not be available for some updates. In this case, you can use the title to hide the update. To do this, list all the available updates via the cmdlet below:
Get-WUList
Next, use your mouse to copy the update title. Ensure it is distinct from other update titles. Now, type below command below to hide the update:
Hide-WUUpdate -Title “Update_Title”
Don’t forget to paste the actual update title in the “Update Title” section.
When prompted to confirm the action, type A, and hit the Enter key. If the command succeeds, the “Get-WUList” lists all the available updates. However, the status of hidden updates appears with the symbol “H” underneath them.
How to determine errors
It is of crucial importance to have as much information as possible about Windows Updates installation processes in order to be able to fix erroneous deployments. The Get-WindowsUpdate cmdlet and the rest of cmdlets available in the module, provide a very detailed log level when managing updates, including status, KB ID, Size or Title.
Centralizing all of the computer logs and analyzing them searching for errors, administrators will always be able to know the patch level of their Windows computers and servers.
The above passages came from this site!
This seems to be not possible by design:
Source 1
Source 2
Source 3
It is impossible for remotely connected users to download stuff from the internet it appears.
Speaking about windows update, you have many options like:
Connection using psexec tool then run wuauclt /detectnow /updatenow
If you are using windows 10 /server 2016 , the tools was replaced with USOClient.exe which is more effective.

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

Installing JRE using Powershell DSC hangs

I'm trying to remote install Java Runtime (8 as it happens) using Powershell DSC on a Windows 2012 R2 box, but it appears to be hanging.
I initially tried to install it using a Chocolatey DSC provider, but that gave me a false success (choco claimed it was installed, but no actual files were unpacked). I chalked this fact up to this: http://powershell.org/wp/forums/topic/issue-installing-java-32-bit-using-package-resource/#post-23187
So I unpacked the exe and extracted the two java MSIs and my DSC configuration looks like this:
Package java8x86
{
Ensure = 'Present'
Name = 'Java 8 Update 45'
Path = (Join-Path $localDscFileDir "Java\jre1.8.0_45\jre1.8.0_45.msi")
Arguments = '/s'
ProductId = '26A24AE4-039D-4CA4-87B4-2F83218045F0'
DependsOn = #("[File]javaMsi")
}
([File]javaMsi copies the .msi files to the remote machine).
When I generate my MOF and Start-DscConfiguration, the output hangs on these lines:
VERBOSE: [DEVTEST-3U2LN5Q]: [[Package]java8x86] Parsing 26A24AE4-039D-4CA4-87B4-2F83218045F0 as an identifyingNumber
VERBOSE: [DEVTEST-3U2LN5Q]: [[Package]java8x86] Parsed 26A24AE4-039D-4CA4-87B4-2F83218045F0 as {26A24AE4-039D-4CA4-87B4-2F83218045F0}
VERBOSE: [DEVTEST-3U2LN5Q]: [[Package]java8x86] Package configuration starting
VERBOSE: [DEVTEST-3U2LN5Q]: [[Package]java8x86] Starting C:\Windows\system32\msiexec.exe with /i "C:\DscFiles\Java\jre1.8.0_45\jre1.8.0_45.msi" /quiet /s
VERBOSE: [DEVTEST-3U2LN5Q]: [[Package]java8x86] Starting process C:\Windows\system32\msiexec.exe with arguments /i "C:\DscFiles\Java\jre1.8.0_45\jre1.8.0_45.msi" /quiet /s
I can't even CTRL-C out of that and have to go to the remote machine and kill the Windows Installer process to cause the Start-DscConfiguration to fail
I'm getting to wits end.... it's 2015 and I can't remote setup a Windows box! So much promised by these technologies....
Remove the line
Arguments = '/s'
or else add
Arguments = '/q'
A year later and I seem to have a solution. Not sure if the original problem was to do with the version of the installer I was installing or not.. but this seems to work for me - for now:
xRemoteFile javaInstaller {
DestinationPath = (Join-Path $localDscFileDir "Java\jreInstaller.exe")
Uri = "http://javadl.oracle.com/webapps/download/AutoDL?BundleId=211999"
}
Package java8
{
Ensure = 'Present'
Name = 'Java 8'
Path = (Join-Path $localDscFileDir "Java\jreInstaller.exe")
Arguments = '/s REBOOT=0 SPONSORS=0 REMOVEOUTOFDATEJRES=1 INSTALL_SILENT=1 AUTO_UPDATE=0 EULA=0 /l*v "C:\DscFiles\Java\jreInstaller.exe.log"' #From https://powershell.org/forums/topic/issue-installing-java-32-bit-using-package-resource/#post-39206
ProductId = '26A24AE4-039D-4CA4-87B4-2F64180101F0'
DependsOn = #("[xRemoteFile]javaInstaller")
}
BTW, that download url corresponds to jre-8u101-windows-x64.exe
For what it's worth, I'm successfully installing JDK 7 with:
Package Java
{
Ensure = 'Present'
Name = "Java 7 Update 72 (64-bit)"
Path = "${InstallerPath}\jdk-7u72-windows-x64.exe"
ProductId = '64A3A4F4-B792-11D6-A78A-00B0D0170720'
Arguments = "/s STATIC=1 WEB_JAVA=0"
}
Cheers,
Andrew
In addition to the above.
Experienced this before in the past. With MSI/EXE installations via DSC, if you do not pass the correct [arguments] it hangs until all threads are killed on the remote box.
Kill all threads and when next you run conf, force the configuration!
start-dscConf -force

Azure Files share doesn't Work

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?