Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

PoshRSJob and Xaml Progress Bar

$
0
0

I’ve been playing around with PoshRSJob and have run into an obstacle that I was hoping someone 

might have some insight into.

I’ve created a function in powershell which manages my downloads from a git (bitbucket) repository, since there can oftentimes be pulls of hundreds of files, I’m using PoshRSJob to improve my download experience. Everything works great, except I can’t seem to figure out how to pass the results from the various runspaces to update my WPF xaml form Progress bar.

Is there something I’m missing when it comes to PoshRSJob that enables this kind of functionality? Here’s an example I tried to put together to see if you wouldn’t mind looking at it?

#if(!(Get-Module -ListAvailable | Where-Object Name -eq "PoshRSJob")){Install-Module -Name PoshRSJob -MaximumVersion 1.7.2.7 -Force}

$AppFiles = 1..100 | ForEach-Object{ New-Object PSObject -Property @{ FileName="File_$_"; Size=$(Get-Random -minimum 2000 -maximum 30000) } }

#region Load External Assemblies
Add-Type -AssemblyName PresentationFramework
[System.Reflection.Assembly]::LoadFrom((Get-ChildItem -Path "C:\Program Files (x86)\Microsoft SDKs" -Recurse | Where-Object Name -eq "Microsoft.Expression.Drawing.dll")[0].FullName) | Out-Null
#endregion

#region Load Xaml into Powershell using XamlReader, and put Named nodes from the form into Powershell objects
[xml]$Xaml = @"<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:fa="http://schemas.fontawesome.io/icons/"
        xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
        Title="Installer - Shared Datamart" Height="500" Width="700"
        ResizeMode="CanMinimize"><!--#region Download Progress Bar--><Grid Grid.Column="1" Grid.Row="0"><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid Grid.Row="0" Width="150" Height="150"><Ellipse Fill="#d6d6d6" Margin="0"/><ed:Arc Name="tabItemDownloadProgressIndicator" ArcThickness="10000" ArcThicknessUnit="Pixel" EndAngle="0" Fill="#00aeef" Margin="0" Stretch="None" StartAngle="0"/><Path Data="M122.12466,50.500001 C161.68188,50.500001 193.74933,79.720514 193.74933,115.76583 193.74933,151.81116 161.68188,181.03166 122.12466,181.03166 82.567459,181.03166 50.5,151.81116 50.5,115.76583 50.5,79.720514 82.567459,50.500001 122.12466,50.500001 z M122.12466,15.500002 C115.11131,15.500001 108.06759,16.15595 101.17562,17.455171 94.320358,18.747478 87.555672,20.68768 81.06208,23.236789 74.633308,25.76045 68.413475,28.90369 62.578602,32.598592 56.821587,36.244188 51.387154,40.460622 46.441212,45.147973 41.568821,49.765626 37.124958,54.88453 33.256836,60.370923 29.443533,65.779557 26.152985,71.598901 23.502686,77.662767 20.881958,83.658967 18.861307,89.955377 17.517124,96.359735 16.181229,102.7246 15.5,109.26228&#xD;&#xA;15.499998,115.76583 15.5,121.88733 16.102737,128.03735 17.287348,134.04314 18.478497,140.08206 20.268742,146.0313 22.59779,151.72893 24.950483,157.48442 27.873993,163.03594 31.274794,168.24126 34.720432,173.51521 38.686134,178.48097 43.053432,183.0212 47.483006,187.62616 52.363304,191.83334 57.559284,195.55202 62.824764,199.32044 68.457726,202.61882 74.313492,205.3822 80.232521,208.17543 86.426445,210.44476 92.745743,212.14876 99.109169,213.86464&#xD;&#xA;105.64935,215.02091 112.21479,215.59747 118.79604,216.17543 125.45329,216.17543 132.03455,215.59747 138.59999,215.02091 145.14017,213.86464 151.50359,212.14876 157.82289,210.44476 164.01682,208.17543 169.93585,205.3822 175.79161,202.61882 181.42458,199.32044 186.69005,195.55202 191.88603,191.83334 196.76633,187.62616 201.19589,183.0212 205.5632,178.48097 209.5289,173.51521 212.97453,168.24126 216.37534,163.03594 219.29884,157.48442 221.65155,151.72893&#xD;&#xA;223.98059,146.0313 225.77084,140.08206 226.96199,134.04314 228.14659,128.03735 228.74933,121.88733 228.74933,115.76583 228.74933,109.26228 228.0681,102.7246 226.73221,96.359735 225.38803,89.955377 223.36737,83.658967 220.74664,77.662767 218.09634,71.598901 214.8058,65.779557 210.99249,60.370923 207.12437,54.88453 202.68051,49.765626 197.80812,45.147973 192.86218,40.460622 187.42775,36.244188 181.67073,32.598592 175.83586,28.90369 169.61603,25.76045&#xD;&#xA;163.18726,23.236789 156.69366,20.68768 149.92897,18.747478 143.07372,17.455171 136.18175,16.15595 129.13803,15.500001 122.12466,15.500002 z M122.12467,0.5 C189.29613,0.50000119 243.74933,52.106267 243.74933,115.76583 243.74933,179.4254 189.29611,231.03166 122.12466,231.03166 54.953205,231.03166 0.5,179.4254 0.5,115.76583 0.5,52.106267 54.95322,0.50000119 122.12467,0.5 z" Fill="White" Margin="-10" Stretch="Fill"/><TextBlock Name="tabItemDownloadProgressValue"  Text="0%" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8 0 0 0" FontSize="25"/></Grid><StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center"><TextBlock FontStyle="Italic" FontSize="11"><Run Text="Total Size:"/><Run Name="tabItemDownloadProgressTotalSize" Text="0 / 0 kb"/></TextBlock><TextBlock FontStyle="Italic" FontSize="11"><Run Text="Total Files:"/><Run Name="tabItemDownloadProgressTotalFiles" Text="0 / 0"/></TextBlock></StackPanel><Button Grid.Row="2" Name="tabItemDownloadPromptButton" Content="Download" FontSize="20" Height="45" FontWeight="Bold"
                    Cursor="Hand" Margin="0 0 0 10" Visibility="Visible"/></Grid><!--#endregion--></Window>"@

$Reader=(New-Object System.Xml.XmlNodeReader $Xaml)
try{$Form=[Windows.Markup.XamlReader]::Load( $Reader )}
catch{Write-Host "Unable to load Windows.Markup.XamlReader. Some possible causes for this problem include: .NET Framework is missing PowerShell must be launched with PowerShell -sta, invalid XAML code was encountered."; exit}

$Xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)}
#endregion

$TotalSize = 0
ForEach($App in $AppFiles){
    $TotalSize += $App.Size
}

$tabItemDownloadPromptButton.Add_Click({

    $ScriptBlock = { $tabItemDownloadProgressIndicator.EndAngle += $($_.Size/$Using:TotalSize * 360) }
    $AppFiles | Start-RSJob -Throttle 20 -Name {$_.FileName} -Batch ([guid]::NewGuid()) -ScriptBlock $ScriptBlock | Wait-RSJob -ShowProgress

})

<#
$tabItemDownloadProgressIndicator.EndAngle = $_.Size/$TotalSize * 360;
#>

$Form.ShowDialog()




Timeout while Invoke-Expression powershell

$
0
0

Hi, is it possible to set timeout while invoke expression in powershell for example:"

$timeoutInSecond = 30;

while($timeout < $running time){

Invoke-Expression "C:\test.exe -verbose -page"

}

Get list of specific groups that a user is a member of in Active Directory

$
0
0

Hi, 

I need to get the list of groups that a user is a member of within Active Directory. However I need to retrieve the specific set of groups characterised by "zz_' written before the name of the group. I.e. its like a filter for groups.  How do i do this?

So ideally I need something that will allow me to input a username and upon running will output all groups the user is a member of starting with 'zz_'

I am very new to Powershell and what be really appreciative if someone could help me out!

Thanks!




Invoke-ProcessASDatabase

$
0
0

I am attempting to process an Analysis Services tabular model via PowerShell... well, we've tried other methods but none of them worked so this is getting to our last resort and as with everything Microsoft, not going well.

My attempt is to follow this guide

https://technet.microsoft.com/en-us/library/hh213141(v=sql.130).aspx

I have installed v16.5.3 of Management Studio (Help->About shows v13.0.16106.4) but when doing the "Get-Command -Module sqlascmdlets", I don't get the list stated (in particular, I don't have Invoke-ASProcessDatabase), what I do have is

 Name                                               ModuleName
 ----                                               ----------
 Add-RoleMember                                     sqlascmdlets
 Backup-ASDatabase                                  sqlascmdlets
 Invoke-ASCmd                                       sqlascmdlets
 Invoke-ProcessCube                                 sqlascmdlets
 Invoke-ProcessDimension                            sqlascmdlets
 Invoke-ProcessPartition                            sqlascmdlets
 Merge-Partition                                    sqlascmdlets
 New-RestoreFolder                                  sqlascmdlets
 New-RestoreLocation                                sqlascmdlets
 Remove-RoleMember                                  sqlascmdlets
 Restore-ASDatabase                                 sqlascmdlets

Where does Invoke-ProcessASDatabase come from?


powershell - add outlook appointment in other user mail box

$
0
0

Hello,

I am need to add appointments in other user mailboxes frequently. I need to achieve this using powershell script. 

What is the best way to automate this process using PS ?

Thanks You.


Prathap SV

Search XML for Tag

$
0
0

I have a script that searches through multiple XML files for a tag and displays it to the user. Now for two of the files that tag name is the same, so writing a script to display it's contents has been easy. However the remaining few all use different tag names and the tag is not in the same place within the hierarchy. This makes things a little difficult. Now I could manually type in this, but I'm expecting this change over time, so a dynamic approach would be better. 

The tag for these files is "agVal". In the test case it is located in three nodes locations within the xml document.

$xmlDocLoc.base.comp.status.dbsm

$xmlDocLoc.base.comp.statusModeConf.mgiw

$xmlDocLoc.base.comp.statusModeConfCont.mgiw

Is there a way to search the whole of an XML Node hierarchy to find the "agVal" tag?

Script for checking if file is being modified.

$
0
0

Hello everybody,

I am looking for an powershell script that will check if an specific file is being modified. I would like to get an error message/variable when the file isn't modified for 1 day. That script we will use to monitor a couple of customers.

is this possible?

How can I change from ConstrainedLanguage to FullLanguage ?

$
0
0

I want to change the Language_Modes of PowerShell v5 from ConstrainedLanguage to FullLanguage.

How can I do this ?

Regards,
Yoshihiro Kawabata


count of Active Users

$
0
0

Hi Team,

Please correct below script, looking count of active users.
Get-BrokerSession |?{$_.SessionState -eq "Active"| measure _.count


subu

Close Form while the others opens doesn't work

$
0
0

Hi there

Short question: How can I close the current form while the other opens at the same time?
The form which should be closed is called $form1
The form which should be open is called $form2.
the Button which opens form2 is called $form1button 

What I did was unter $form1button_Klick { 

###the action here####

form1.close () }

But this doesnt work

fyi there are more forms but the mainform is form1. What do I wrong?

Regards



Powershell log external process to file and keep abielity to interact with it

$
0
0

Is it possible to write output of external process started by powershell using Start-Transcript but without using RedirectStandardOutput as I have implemented simple interactivity:

Start-Transcript-path "C:\test.txt"-append

$ps = new-object System.Diagnostics.Process
$ps.StartInfo.Filename="C:\test.exe"
$ps.StartInfo.Arguments=" -verbose -page"
$ps.StartInfo.RedirectStandardInput= $true;
$ps.StartInfo.UseShellExecute= $false
$ps.start()while(! $ps.HasExited){Start-Sleep-s 5
    write-output "I will press button now..."Press-Button}Stop-Transcript

This will show me the output and allow to interact with it, but Start-Transcript will nit log that as it is external process. Is there any other way to stream output from external power shell process?

Logon PowerShell script to set corporate wallpaper for different resolutions

$
0
0

Hi All,

I would like to get help here on setting corporate wallpaper through GPO. Following are the requirement.

  • We do have different sized images for corporate wallpaper, which needs to set for different resolution.
  • Most users are having dual monitors. Correctly sized wallpaper needs to be set for both monitors.
  • All clients are running Windows 7 and servers are running Windows 2012 R2, which means PowerShell scripts can be set as logon script.

I did check many forum topics, but none seems to matching my exact requirement. So, please help.

Thank you 🙂


Want to know more about Powershell DSC

$
0
0

Hi Friends,

I am very new to Powershell DSC and I would like to implement and test it, so I would like to know more on below points :

1. Why do we need PowerShell DSC ? 

2. What are the PowerShell DSCs advantages over other automation tools ? or any unique property or functionality is highlighted ?

3. When i explored about some tasks using PowerShell DSC, I can do the same with help of GPOs. Example : I can create a good windows patch management environment using DSC (something like automating the patching on servers) This same job can be done by defining policies on GPO. So what would the advantage over this ?

Your answers/suggestions/feedbacks are most welcome

Thanks

Arun 

Parameter set by number of positional parameters

$
0
0

I am creating a cmdlet that has 2 different parameter sets.  One parameter set uses a single positional parameter, another uses two positional parameters, all integers.  For some reason powershell doesn't recognize this and errors on me.

Here is some pseudo code that (I think) should work, but doesn't.

Function foo {
    [CmdletBinding(DefaultParameterSetName="A", PositionalBinding=$false)]
    param(

        [Parameter(Mandatory=$true, ParameterSetName="A", Position=0)]
        [int]$varA,

        [Parameter(Mandatory=$true, ParameterSetName="B", Position=0)]
        [int]$varB1,

        [Parameter(Mandatory=$true, ParameterSetName="B", Position=1)]
        [int]$varB2


    )

    process {

        switch ($PSCmdlet.ParameterSetName) {

            "A" {
              Write-Host "Parameter Set A chosen"
            }"B" {
               Write-Host "Parameter Set B chosen"
            }

        }

    }

}

Here is some output, showing that using a second positional parameter doesn't cause it to use set B:

> foo 1
Parameter Set A chosen> foo 1 2
foo : A positional parameter cannot be found that accepts argument '2'.
At line:1 char:1+ foo 1 2+ ~~~~~~~+ CategoryInfo          : InvalidArgument: (:) [foo], ParameterBindingException+ FullyQualifiedErrorId : PositionalParameterNotFound,foo

If I change the default Parameter Set to B, then here is what I get:

> foo 1
cmdlet foo at command pipeline position 1
Supply values for the following parameters:
requiredB2:> foo 1 2
Parameter Set B chosen

If I remove the default Parameter Set, then I get:

> foo 1
foo : Parameter set cannot be resolved using the specified named parameters.> foo 1 2
foo : Parameter set cannot be resolved using the specified named parameters.

What this tells me is that powershell doesn't pay any attention to the number of positional parameters when choosing a parameter set.  It seems like it should be trivial to do so, perhaps there is an option I am overlooking?

I set PositionalBinding to $false because in my script, there are other parameters in each set, and I suspected that it would be necessary to disable PositionalBinding to prevent those parameters from entering the position count.

Just so you understand a use case for doing this... imagine a cmdlet to grab users from a database.  You can either:

  1. get-DBUser username
  2. get-DBUser firstname lastname

It would be nice not to have to type "get-dbuser -firstname foo -lastname bar" 

Does anyone know how I can make this work?


PowerShell ISE Freezes after executing WinForms

$
0
0
Hello, I've been having an issue with my PowerShell ISE. I am currently developing a PowerShell script that generates Windows Forms for gathering and displaying data. From what I can tell, the application runs and works great. However, after I execute the code once in the ISE (and close the app/stop execution gracefully); if I leave the ISE idle, for about 10 minutes, the ISE will freeze and I have to crash it with Task Manager. If winform code has not been executed, ISE works fine indefinitely. Thoughts on why my ISE constantly crashes when working on winform based scripts? Thanks.

Script will throw error when a value is empty

$
0
0

Hello,

I have a simple script which sets a VM to have an availability set if one is specifies, and does not if there isn't one specified.  The script works, but it throws and error.  I have tried using -erroraction runsilent but I still see an error. I would imagine there is a much better way to accomplish this but I'm new to PowerShell:

 
#Check to see whether or not an Availability Set will be used.
    $AVstatus = Get-AzureRmAvailabilitySet -ResourceGroupName $RGname -Name $AVset -ErrorAction Ignore
    if ($AVStatus -eq $null)
    {"No Availabilty set was specified.  This VM will be deployed without one."
        $vm = New-AzureRmVMConfig -VMName $vmName -VMSize $vmsize
    }
    else
    {"Machine will be deployed to the following Availability set: $AVset "
        $vm = New-AzureRmVMConfig -VMName $vmName -VMSize $vmsize -AvailabilitySetID "/subscriptions/$subscriptionID/resourceGroups/$RGname/providers/Microsoft.Compute/availabilitySets/$AVset"
    }

When there is no AVset specified in the excel spreadsheet I receive the error below, but ultimately the script works in either case:

Get-AzureRmAvailabilitySet : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try

the command again.

At line:1 char:61

+ ... zureRmAvailabilitySet -ResourceGroupName $RGname -Name $AVset -ErrorA ...

+                                                            ~~~~~~

    + CategoryInfo          : InvalidData: (:) [Get-AzureRmAvailabilitySet], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.Compute.GetAzureAvailabilitySetCommand

'Set-ExecutionPolicy' is not recognized as an internal or external command

$
0
0

Hi,

As part of software update, i wanted to run the command Set-ExecutionPolicy. On executing, i am stuck with the error 'Set-ExecutionPolicy' is not recognized as an internal or external command. Please let me know what need to be done.

Thanks

Bulk Delete Computer from AD using list of partial names

$
0
0

Hello!

I am trying to bulk delete computers from Active Directory using a PowerShell script. The list I have, however, only has partial names. 

e.g. my list is like this: 

199255 

326955 

128793

but the full computer names are like "BLDG199255ROOM" or "BLDG326955ROOM"

I am trying to use this list to delete the machines from active directory. Here is what I've mustered so far (I'm very new to PowerShell, and really wanting to learn):

$computers = get-content C:\computers.txt | Get-ADComputer -Properties ProtectedFromAccidentalDeletion
$computers | Set-ADObject -ProtectedFromAccidentalDeletion $false
$computers | Remove-ADComputer
If anyone could help me out, I would greatly appreciate it. 

run Office Online question

$
0
0

I need to do the following.    Machine abc does not have Office installed locally.   A user who is logged into machine abc goes to a network share and double clicks on an Office doc (.xlsx, docx etc....)   I need that document to launch in Office.Live.com

Now, I can modify the File Association and point any .xlsx or docx file to run a custom PowerShell Script.  This PowerShell script looks like this:  

(if an Excel file was clicked on.......)

if (Test-Path  "C:\Program Files\Microsoft Office 15\root\office15\Excel.exe"){start-sleep -m 1}
ELSE {cmd.exe /c "C:\Program Files\Internet Explorer\iexplore.exe" "https://office.live.com/start/Excel.aspx?"}

My issue is this does not open the document that was actually clicked on.    How would that be done?   So the file could be something like this:    \\Server\Share\SubFolder\SubFolder2\Expense Report for January 2017.xlsx

How would you launch that in Office.Live?


mqh7

PoshRSJob and Xaml Progress Bar

$
0
0

I’ve been playing around with PoshRSJob and have run into an obstacle that I was hoping someone 

might have some insight into.

I’ve created a function in powershell which manages my downloads from a git (bitbucket) repository, since there can oftentimes be pulls of hundreds of files, I’m using PoshRSJob to improve my download experience. Everything works great, except I can’t seem to figure out how to pass the results from the various runspaces to update my WPF xaml form Progress bar.

Is there something I’m missing when it comes to PoshRSJob that enables this kind of functionality? Here’s an example I tried to put together to see if you wouldn’t mind looking at it?

#if(!(Get-Module -ListAvailable | Where-Object Name -eq "PoshRSJob")){Install-Module -Name PoshRSJob -MaximumVersion 1.7.2.7 -Force}

$AppFiles = 1..100 | ForEach-Object{ New-Object PSObject -Property @{ FileName="File_$_"; Size=$(Get-Random -minimum 2000 -maximum 30000) } }

#region Load External Assemblies
Add-Type -AssemblyName PresentationFramework
[System.Reflection.Assembly]::LoadFrom((Get-ChildItem -Path "C:\Program Files (x86)\Microsoft SDKs" -Recurse | Where-Object Name -eq "Microsoft.Expression.Drawing.dll")[0].FullName) | Out-Null
#endregion

#region Load Xaml into Powershell using XamlReader, and put Named nodes from the form into Powershell objects
[xml]$Xaml = @"<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:fa="http://schemas.fontawesome.io/icons/"
        xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
        Title="Installer - Shared Datamart" Height="500" Width="700"
        ResizeMode="CanMinimize"><!--#region Download Progress Bar--><Grid Grid.Column="1" Grid.Row="0"><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid Grid.Row="0" Width="150" Height="150"><Ellipse Fill="#d6d6d6" Margin="0"/><ed:Arc Name="tabItemDownloadProgressIndicator" ArcThickness="10000" ArcThicknessUnit="Pixel" EndAngle="0" Fill="#00aeef" Margin="0" Stretch="None" StartAngle="0"/><Path Data="M122.12466,50.500001 C161.68188,50.500001 193.74933,79.720514 193.74933,115.76583 193.74933,151.81116 161.68188,181.03166 122.12466,181.03166 82.567459,181.03166 50.5,151.81116 50.5,115.76583 50.5,79.720514 82.567459,50.500001 122.12466,50.500001 z M122.12466,15.500002 C115.11131,15.500001 108.06759,16.15595 101.17562,17.455171 94.320358,18.747478 87.555672,20.68768 81.06208,23.236789 74.633308,25.76045 68.413475,28.90369 62.578602,32.598592 56.821587,36.244188 51.387154,40.460622 46.441212,45.147973 41.568821,49.765626 37.124958,54.88453 33.256836,60.370923 29.443533,65.779557 26.152985,71.598901 23.502686,77.662767 20.881958,83.658967 18.861307,89.955377 17.517124,96.359735 16.181229,102.7246 15.5,109.26228&#xD;&#xA;15.499998,115.76583 15.5,121.88733 16.102737,128.03735 17.287348,134.04314 18.478497,140.08206 20.268742,146.0313 22.59779,151.72893 24.950483,157.48442 27.873993,163.03594 31.274794,168.24126 34.720432,173.51521 38.686134,178.48097 43.053432,183.0212 47.483006,187.62616 52.363304,191.83334 57.559284,195.55202 62.824764,199.32044 68.457726,202.61882 74.313492,205.3822 80.232521,208.17543 86.426445,210.44476 92.745743,212.14876 99.109169,213.86464&#xD;&#xA;105.64935,215.02091 112.21479,215.59747 118.79604,216.17543 125.45329,216.17543 132.03455,215.59747 138.59999,215.02091 145.14017,213.86464 151.50359,212.14876 157.82289,210.44476 164.01682,208.17543 169.93585,205.3822 175.79161,202.61882 181.42458,199.32044 186.69005,195.55202 191.88603,191.83334 196.76633,187.62616 201.19589,183.0212 205.5632,178.48097 209.5289,173.51521 212.97453,168.24126 216.37534,163.03594 219.29884,157.48442 221.65155,151.72893&#xD;&#xA;223.98059,146.0313 225.77084,140.08206 226.96199,134.04314 228.14659,128.03735 228.74933,121.88733 228.74933,115.76583 228.74933,109.26228 228.0681,102.7246 226.73221,96.359735 225.38803,89.955377 223.36737,83.658967 220.74664,77.662767 218.09634,71.598901 214.8058,65.779557 210.99249,60.370923 207.12437,54.88453 202.68051,49.765626 197.80812,45.147973 192.86218,40.460622 187.42775,36.244188 181.67073,32.598592 175.83586,28.90369 169.61603,25.76045&#xD;&#xA;163.18726,23.236789 156.69366,20.68768 149.92897,18.747478 143.07372,17.455171 136.18175,16.15595 129.13803,15.500001 122.12466,15.500002 z M122.12467,0.5 C189.29613,0.50000119 243.74933,52.106267 243.74933,115.76583 243.74933,179.4254 189.29611,231.03166 122.12466,231.03166 54.953205,231.03166 0.5,179.4254 0.5,115.76583 0.5,52.106267 54.95322,0.50000119 122.12467,0.5 z" Fill="White" Margin="-10" Stretch="Fill"/><TextBlock Name="tabItemDownloadProgressValue"  Text="0%" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8 0 0 0" FontSize="25"/></Grid><StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center"><TextBlock FontStyle="Italic" FontSize="11"><Run Text="Total Size:"/><Run Name="tabItemDownloadProgressTotalSize" Text="0 / 0 kb"/></TextBlock><TextBlock FontStyle="Italic" FontSize="11"><Run Text="Total Files:"/><Run Name="tabItemDownloadProgressTotalFiles" Text="0 / 0"/></TextBlock></StackPanel><Button Grid.Row="2" Name="tabItemDownloadPromptButton" Content="Download" FontSize="20" Height="45" FontWeight="Bold"
                    Cursor="Hand" Margin="0 0 0 10" Visibility="Visible"/></Grid><!--#endregion--></Window>"@

$Reader=(New-Object System.Xml.XmlNodeReader $Xaml)
try{$Form=[Windows.Markup.XamlReader]::Load( $Reader )}
catch{Write-Host "Unable to load Windows.Markup.XamlReader. Some possible causes for this problem include: .NET Framework is missing PowerShell must be launched with PowerShell -sta, invalid XAML code was encountered."; exit}

$Xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)}
#endregion

$TotalSize = 0
ForEach($App in $AppFiles){
    $TotalSize += $App.Size
}

$tabItemDownloadPromptButton.Add_Click({

    $ScriptBlock = { $tabItemDownloadProgressIndicator.EndAngle += $($_.Size/$Using:TotalSize * 360) }
    $AppFiles | Start-RSJob -Throttle 20 -Name {$_.FileName} -Batch ([guid]::NewGuid()) -ScriptBlock $ScriptBlock | Wait-RSJob -ShowProgress

})

<#
$tabItemDownloadProgressIndicator.EndAngle = $_.Size/$TotalSize * 360;
#>

$Form.ShowDialog()



Viewing all 21975 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>