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

Powershell Combobox populate from xml and ComboBox 2 based on ComboBox 1 Selection

$
0
0

This is the script I am using for my drop down box.

the script created to rename computers based in location and department 

so it ask users to choose their location (building and the floor) and the department, every building and department has a code and then users enter their ext number 

Headquarter Building = "HQ"

Airport Office = "AIR"

Laboratories = "LAB"

Information Technology = "IT" 

Human Resources = "HR" 

Finance = "FIN" 

After choosing location and department and entering ext number  the computer named is created like this 'HQ-HR-3456"

SO what I'm stock in is this

1- need to load data or populate Combobox from xml file 

2- when they selecting building  in first ComboBox  then the second ComboBox  shows the floors

Is there a way to make these 2 things happen?

i do my research last two weeks but i ended empty handed so sad

so i try my best to do so. 

i write my xml file but not sure

<?xml version="1.0" encoding="utf-8" ?> <root><campuses><campus uniquecode="LDN"   label="London"><buildings><building uniquecode="HQ" label="Headquarter Building"><floors><floor uniquecode="G" label="Ground Floor" /><floor uniquecode="F" label="First Floor" /><floor uniquecode="S" label="Second Floor" /><floor uniquecode="T" label="Third Floor" /></floors></building><building uniquecode="LHRO" label="London Airport Office"><floors><floor uniquecode="G" label="Ground Floor" /><floor uniquecode="F" label="First Floor" /><floor uniquecode="S" label="Second Floor" /><floor uniquecode="T" label="Third Floor" /></floors></building><building uniquecode="LAP" label="Lap Building"><floors><floor uniquecode="G" label="Ground Floor" /><floor uniquecode="F" label="First Floor" /><floor uniquecode="S" label="Second Floor" /><floor uniquecode="T" label="Third Floor" /></floors></building></buildings></campus></campuses><departments><department uniquecode="CEO" label="CEO" /><department uniquecode="LABS" label="Laboratory" /><department uniquecode="IT" label="Information Technology" /><department uniquecode="HR" label="Human Resources" /><department uniquecode="FIN" label="Finnance" /></departments></root>

this is my scripts 

#Loading Assemnlies
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$Global:ErrorProvider = New-Object System.Windows.Forms.ErrorProvider



function Set-ComputerName
{
 $ErrorProvider.Clear()
    if ($DDBBuilding.Text.Length -eq 0) 
    {
        $ErrorProvider.SetError($GBBuilding, "Please Choose Your Building")
    }

    elseif ($DDBFloornumber.Text.Length -eq 0) 
    {
        $ErrorProvider.SetError($GBFloornumber, "Please Choose Your Floor")
    }

    elseif ($DDBSector.Text.Length -eq 0) 
    {
        $ErrorProvider.SetError($GBSector, "Please Choose Your Sector")
    }

    #Validation Rule for computer names.
    elseif ($TBExtnumber.Text.Length -gt 4 )
    {
        $ErrorProvider.SetError($GBExtnumber, "Your Extension Number invalid, Please Enter Your Extension Number")
    }
    elseif ($TBExtnumber.Text.Length -eq 0 )
    {
        $ErrorProvider.SetError($GBExtnumber, "Your Extension Number invalid, Please Enter Your Extension Number")
    }

    else 
    {

   $OutputBox.Text = $DDBBuilding.SelectedItem.ToSTRING() + $DDBFloornumber.SelectedItem.ToSTRING() + "-" + $DDBSector.SelectedItem.ToSTRING() + "-" + $TBExtnumber.Text.ToUpper()

   $ComputerName = $DDBBuilding.SelectedItem.ToSTRING() + $DDBFloornumber.SelectedItem.ToSTRING() + "-" + $DDBSector.SelectedItem.ToSTRING() + "-" + $TBExtnumber.Text.ToUpper()
   Rename-Computer -NewName "$ComputerName"

   Restart-Computer
}

}

#Start To Creat Form
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(400,500)
$Form.StartPosition = "CenterScreen"
$Form.Text = "change Computer name"

#Creating DropDownBox
$DDBBuilding = New-Object System.Windows.Forms.ComboBox
$DDBBuilding.Location = New-Object System.Drawing.Size(85,30)
$DDBBuilding.Size = New-Object System.Drawing.Size(200,50)
$DDBBuilding.Height = 200

$Form.Controls.Add($DDBBuilding)

$Details = @("HQ","airport","Lab")

foreach($Detail in $Details){

$DDBBuilding.Items.Add($Detail)

}

#Add a Label to input box
$GBBuilding = New-Object System.Windows.Forms.GroupBox
$GBBuilding.Location = New-Object System.Drawing.Size(80,10)
$GBBuilding.Size = New-Object System.Drawing.Size(210,50)
$GBBuilding.Text = "Choose Your Building"
$GBBuilding.BackColor = "Transparent"
$GBBuilding.AutoSize = $true

$Form.Controls.Add($GBBuilding)


#Creating DropDownBox
$DDBFloornumber = New-Object System.Windows.Forms.ComboBox
$DDBFloornumber.Location = New-Object System.Drawing.Size(85,90)
$DDBFloornumber.Size = New-Object System.Drawing.Size(200,50)
$DDBFloornumber.Height = 200

$Form.Controls.Add($DDBFloornumber)

$Details = @("G","F","S")

foreach($Detail in $Details){

$DDBFloornumber.Items.Add($Detail)

}

#Add a Label to input box
$GBFloornumber = New-Object System.Windows.Forms.GroupBox
$GBFloornumber.Location = New-Object System.Drawing.Size(80,70)
$GBFloornumber.Size = New-Object System.Drawing.Size(210,50)
$GBFloornumber.Text = "Choose Your Floor"
$GBFloornumber.BackColor = "Transparent"
$GBFloornumber.AutoSize = $true

$Form.Controls.Add($GBFloornumber)


#Creating DropDownBox
$DDBSector = New-Object System.Windows.Forms.ComboBox
$DDBSector.Location = New-Object System.Drawing.Size(85,150)
$DDBSector.Size = New-Object System.Drawing.Size(200,50)
$DDBSector.Height = 200

$Form.Controls.Add($DDBSector)

$Details = @("FIN","HR","IT")

foreach($Detail in $Details){

$DDBSector.Items.Add($Detail)

}

#Add a Label to input box
$GBSector = New-Object System.Windows.Forms.GroupBox
$GBSector.Location = New-Object System.Drawing.Size(80,130)
$GBSector.Size = New-Object System.Drawing.Size(210,50)
$GBSector.Text = "Choose Your Sector"
$GBSector.BackColor = "Transparent"
$GBSector.AutoSize = $true

$Form.Controls.Add($GBSector)


#Add an Input box
$TBExtnumber = New-Object System.Windows.Forms.TextBox
$TBExtnumber.Location = New-Object System.Drawing.Size(85,210) 
$TBExtnumber.Size = New-Object System.Drawing.Size(200,50)
$TBExtnumber.TabIndex = "1"

$Form.Controls.Add($TBExtnumber)


#Add a Label to input box
$GBExtnumber = New-Object System.Windows.Forms.GroupBox
$GBExtnumber.Location = New-Object System.Drawing.Size(80,190)
$GBExtnumber.Size = New-Object System.Drawing.Size(210,50)
$GBExtnumber.Text = "Enter Your Extension Number:"
$GBExtnumber.BackColor = "Transparent"
$GBExtnumber.AutoSize = $true

$Form.Controls.Add($GBExtnumber)

#Creat a outputbox
$OutputBox = New-Object System.Windows.Forms.RichTextBox
$OutputBox.Location = New-Object System.Drawing.Size(85,270)
$OutputBox.Size = New-Object System.Drawing.Size(200,50)
$OutputBox.Multiline = $true

$Form.Controls.Add($OutputBox)

#Add a Label to input box
$GBOutputBox = New-Object System.Windows.Forms.GroupBox
$GBOutputBox.Location = New-Object System.Drawing.Size(80,250)
$GBOutputBox.Size = New-Object System.Drawing.Size(210,80)
$GBOutputBox.Text = "Your New Computer Name is:"
$GBOutputBox.BackColor = "Transparent"
$GBOutputBox.AutoSize = $true

$Form.Controls.Add($GBOutputBox)

#Create a Button
$ButtonValidate = New-Object System.Windows.Forms.Button 
$ButtonValidate.Location = New-Object System.Drawing.Size(60,350) 
$ButtonValidate.Size = New-Object System.Drawing.Size(60,30) 
$ButtonValidate.Text = "Validate"
$ButtonValidate.TabIndex = "2"

$ButtonValidate.Add_Click({Set-ComputerName})
$Form.Controls.Add($ButtonValidate)


$form.ShowDialog()
Big thanks to help in advanced :)



[Announcement] “Windows PowerShell” Forum will be migrating to a new home on Microsoft Q&A!

$
0
0

This “Windows PowerShell” Forum will be migrating to a new home on Microsoft Q&A!

 

We’ve listened to your feedback on how we can enhance the forum experience. Microsoft Q&A allows us to add new functionality and enables easier access to all the technical resources most useful to you, like Microsoft Docs and Microsoft Learn. 

 

Now until July 26, 2020:

 

From July 27, 2019 until August 10, 2020:

  • New posts – We invite you to post new questions in the “Windows PowerShell” forum’s new home on Microsoft Q&A. The current forum will not allow any new questions.
  • Existing posts – Interact here with existing content, answer questions, provide comments, etc.

 

August 10, 2020 onward:

  • This forum will be closed to all new and existing posts and all interactions will be in Microsoft Q&A.

 

We are excited about moving to Microsoft Q&A and seeing you there.        

Learn More


Please remember to mark the replies as answers if they help.
"Windows 10 Installation, Setup, and Deployment" forum will be migrating to a new home onMicrosoft Q&A (Preview)!
We invite you to post new questions in the "Windows 10 Installation, Setup, and Deployment" forum’s new home on Microsoft Q&A (Preview)!
For more information, please refer to the sticky post.

Using PS Script to Retrive Local Printer User Permissions on Windows 7

$
0
0

The PS Command Get-Printer is not recognized in Windows 7.

I have used theget-wmiobject-classwin32_printer-Namespace"root\cimv2"|where {$_.Default-eq'True' } command to identified the Share Printer.

I used the PS Command (Get-CimClass-ClassNameWin32_Printer).CimClassMethods to identify the classes, however I am not sure how to retrieve usrs with their permissions setting.

Any help would be greatly appreciated.

Thank you

Larry (email: lpsunaz@cox.net

Copy snapshot of a managed disk to same subscription

$
0
0

Please help.I keep getting below this error.

Line |
  32 |  New-AzSnapshot -Snapshot $snapshotConfig -SnapshotName $snapshotName  …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Changing property 'sourceResourceId' is not allowed for existing disk 'Astorage_snapshot'.
     | ErrorCode: BadRequest ErrorMessage: Changing property 'sourceResourceId' is not allowed for
     | existing disk 'AO_storage_snapshot'. ErrorTarget:  StatusCode: 400 ReasonPhrase: Bad Request
     | OperationID : 82e78192-84b2-4264-a540-577d0050e1b4

Here is my script

#Provide the subscription Id of the subscription where snapshot exists
$sourceSubscriptionId='876c1648-5bd4-444b-8eaa-168f576b8457'

#Provide the name of your resource group where snapshot exists
$sourceResourceGroupName='WNS'

#Provide the name of the snapshot
$snapshotName='WNSstorage_snapshot'

#Set the context to the subscription Id where snapshot exists
Select-AzSubscription -SubscriptionId $sourceSubscriptionId

#Get the source snapshot
$snapshot= Get-AzSnapshot -ResourceGroupName $sourceResourceGroupName -Name $snapshotName

#Provide the subscription Id of the subscription where snapshot will be copied to
#If snapshot is copied to the same subscription then you can skip this step
#$targetSubscriptionId='yourTargetSubscriptionId'

#Name of the resource group where snapshot will be copied to
$targetResourceGroupName='WNS'

#Set the context to the subscription Id where snapshot will be copied to
#If snapshot is copied to the same subscription then you can skip this step
#Select-AzSubscription -SubscriptionId $targetSubscriptionId

#We recommend you to store your snapshots in Standard storage to reduce cost. Please use Standard_ZRS in regions where zone redundant storage (ZRS) is available, otherwise use Standard_LRS
$snapshotConfig = New-AzSnapshotConfig -SourceResourceId $snapshot.Id -Location $snapshot.Location -CreateOption Copy -SkuName Standard_LRS

#Create a new snapshot in the target subscription and resource group
New-AzSnapshot -Snapshot $snapshotConfig -SnapshotName $snapshotName -ResourceGroupName $targetResourceGroupName 



Get-ChildItem files with exclamation points

$
0
0

I have a folder that has a lot of files with an exclamation point in them and I am trying to move them to another folder. However, powershell sees the path fullname but for some reason will not move the item.

PowerShell New-VHD will not take VolumeID as Path argument

$
0
0
 New-VHD -SizeBytes 16GB -Fixed -Path '\\?\Volume{a3d75r32-1fbf-46fa-ac84-795c1dm9afe2}\TMP.vhdx'

It's interpreted as a relative path.

New-VHD : Failed to create the virtual hard disk.
The system failed to create 'C:\\?\Volume{...}\TMP.vhdx': The filename, directory name, or volume label syntax is incorrect.
(0x8007007B).

If I use quotes: "VolumeID" the error is Illegal characters in path.

VolumeID works like a champ in Hyper-V manager.  I enter the VolumeID in the "Location field" in the New Virtual Hard Disk Wizard>Specify Name and Location dialog.

Is there another way to reference VolumeID that will work with the New-VHD cmdlet?

Other VHD creation cmdlets that will take a filesystem object?


Advanced Tab of Internet Options change registry key with PowerShell

$
0
0

Hi everyone,

I want to uncheck “Check for Server Certificate Revocation ” and checked all tsl/ssl in the Advanced Tab of Internet Options with a PowerShell command.

I searched Google but did’t find anything.

Please help me.
Thank you.

Mouse Click

$
0
0

I'm looking for mouse click function in powershell script  since last night and i can't find no one that work.

I have been tried the script from link but don't work. Does anybody some powershell script to simulate mouse left and right click?

Thanks!


Error '0x80073701' while trying to install Containers Windows feature

$
0
0

Dear Community,

I'm facing an issue trying to install Windows Docker, more specifically its containers feature, to a Windows 2016 server.

I tried installing Docker using the following set of commands on Powershell ran as Admin:

Install-Module DockerMsftProvider -Force

cd C:\Users\s7qzqx\AppData\Local\Temp\DockerMsftProvider
Start-BitsTransfer -Source https://dockermsft.blob.core.windows.net/dockercontainer/docker-19-03-5.zip -Destination docker-19-03-5.zip
Get-FileHash -Path docker-19-03-5.zip -Algorithm SHA256
Install-Package -Name docker -ProviderName DockerMsftProvider -Verbose

And then restarting the server. The reason why I used the 3 commands in the middle is because the package couldn't be found and therefore installed.

Anyway, that seemed to work and I'm now able to check Docker version using 'docker --version' command.

The only thing that failed is adding the containers feature, which gives the following error:

WARNING: A restart is required to enable the containers feature. Please restart your machine.

Install-package : The request do add or remove features on the specified server failed.

Installation of one or more roles, role services, or features failed.

The referenced assembly could not be found. Error: 0x80073701

At line:1 char:1

+ Install-Package -Name docker -ProviderName DockerMsftProvider -Verbos ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo            : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:String) [Install-Package], Exception

+ FullyQualifiedErrorId : DISMAPI_Error__Failed_To_Enable_Updates,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand,Microsoft.Powershell.PackageManagement.Cmdlets.InstallPackage

(I can't insert images because my account is not verified for some reason)

The same error happens even after restarting the machine and running this command: 'Install-WindowsFeature -Name Containers'.

I found online that it might have to do with some registry entries in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\PackageDetect" that were created and orphaned and that the solution would be to delete them, but personally I'm afraid to delete Windows registry entries without fully knowing what I'm doing.

Do you know if there's a precise way to know what to delete and what to not touch, or if there's any other solution/workaround to fix this error and complete Docker's installation?

Thanks a lot in advance,

Nicolò

[Powershell] Get-MpComputerStatus returns error

$
0
0

Hello, 

I am trying to get some Information About Windows Defender using the PowerShell Get-MpComputerstatus CMDLet.

But i only get different Errors depending on the System.

I tried this on following Windows Configurations and got following Errors:

- Windows 10 Enterprise 1903 Build 18362.959 (Windows Defender Aktive)

The Problem is, that when i try to use the cmdlet i get following errors:
Get-MpComputerStatus : Fehler beim Vorgang: 0x800106ba
In Line:1 Char:1+ Get-MpComputerStatus+ ~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (MSFT_MpComputerStatus:ROOT\Microsoft\...pComputerStatus) [Get-MpComputerS
   tatus], CimException+ FullyQualifiedErrorId : HRESULT 0x800106ba,Get-MpComputerStatus

Windows 10 Enterprise 1809 Build 17763.1339 (Defender not Aktive)

Get-MpComputerStatus : The extrinsic Method could not be executed.
In Line:1 Char:1+ Get-MpComputerStatus+ ~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : MetadataError: (MSFT_MpComputerStatus:ROOT\Microsoft\...pComputerStatus) [Get-MpComputerStatus], CimException+ FullyQualifiedErrorId : MI RESULT 16,Get-MpComputerStatus

Windows 10 Enterprise 1803 Build 17134.1610 (Other Antivirus Programm (McAfee))

Get-MpComputerStatus : Es ist ein allgemeiner Fehler aufgetreten, für den kein spezifischerer Fehlercode verfügbar ist.
In Zeile:1 Zeichen:2
+  Get-MpComputerStatus+  ~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (MSFT_MpComputerStatus:ROOT\Microsoft\...pComputerStatus) [Get-MpComputerStatus], CimException+ FullyQualifiedErrorId : HRESULT 0x800106ba,Get-MpComputerStatus

What am i trying to do is to find out if Windows Defender is Active or not.

I wanted to do this with the Get-MpComputerStatus cmdlet but as you already know i get These Errors and i dont know why thes occur.

Help would be Appreciated :D .


Remove ACL Entry from an OU

$
0
0

Hi

Is there a way I can remove a user (in this case "NT Authority\Authenticated Users") from an OU using Powershell. Inheritance is blocked.

Ive attempted to the below but it doesnt seem to work: Any suggestions?

    $acl = Get-Acl -Path "Path to OU"    
foreach($acc in $acl.access ) 
{ 
    $value = $acc.IdentityReference.Value 
    if($value -match "NT Authority\Authenticated Users") 
    { 
        $ACL.RemoveAccessRule($acc) | Out-Null 
        Set-Acl -Path "Path to OU" -AclObject $acl -ErrorAction Stop 
        Write-Host "Remove ACL Entry: $value  form" 
    } 
}"

ran Get-WindowsUpdateLog cmdlet for multiple machines remotely and get the logs into common location

$
0
0

windows update log by design is updating during patching once we ran get-windowsupdatelog cmdlet then only log creates on user desktops it is possible to ran Get-WindowsUpdateLog cmdlet for multiple machines remotely and get the logs into common location

PS C:\Windows\system32> Get-WindowsUpdateLog

Converting C:\Windows\logs\WindowsUpdate into C:\Users\Admin\Desktop\WindowsUpdate.log ...


    Directory: C:\Users\Admin\AppData\Local\Temp\WindowsUpdateLog


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       25-07-2020     20:43                SymCache

Input
----------------
File(s):
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.5.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.6.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.7.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.8.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.9.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.10.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.11.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.12.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.13.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.14.etl

0.00%4.69%9.38%14.08%18.77%23.46%28.15%32.84%37.54%42.23%46.92%51.61%56.30%61.00%65.69%70.38%75.07%79.77%84.46%89.15%93.84%98.53%100.00%

Output
----------------
DumpFile:           C:\Users\Admin\AppData\Local\Temp\WindowsUpdateLog\wuetl.CSV.tmp.00000

The command completed successfully


Input
----------------
File(s):
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.15.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.16.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.17.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.18.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.160520.153.19.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20200725.181021.300.1.etl

0.00%10.53%21.05%31.58%42.11%52.63%63.16%73.68%84.21%94.74%100.00%

Output
----------------
DumpFile:           C:\Users\Admin\AppData\Local\Temp\WindowsUpdateLog\wuetl.CSV.tmp.00001

The command completed successfully.

WindowsUpdate.log written to C:\Users\Admin\Desktop\WindowsUpdate.log

Invalid class problem

$
0
0

I am having a problem with this.

PS C:\Users\administrator> new-vhd fu.vhdx -SizeBytes 10gb -Dynamic
new-vhd : The operation on computer 'WIN10' failed: Invalid class
At line:1 char:1+ new-vhd fu.vhdx -SizeBytes 10gb -Dynamic+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (:) [New-VHD], VirtualizationException+ FullyQualifiedErrorId : Unspecified,Microsoft.Vhd.PowerShell.Cmdlets.NewVhd

The 'invalid class' error happens on any cmdlet found in the Hyper-V module.  I have tried uninstalling/reinstalling the Hyper-V PowerShell and management features.  This is a Windows 10 VM, so I am not installing/uninstalling Hyper-V itself, just the PowerShell and management.  I use this system for a lot of scripting, and this is the only module that is giving me a problem.

I don't know what I might try next.  Appreciate any guidance.


. : | : . : | : . tim

Exclude few sub folders while copying to remote server

$
0
0

Hi.

I am trying to copy the folder and files from one server to another, based on a configuration xml.

The source folder contains data as below:

Backup

Backup\folder1

Backup\folder2

Backup\folder3 .. like this

I want to exclude folder2, folder4, folder5 and copy the other folders to destination.

Also, when copying other folders, I want to copy those folders and only the files ending with .bak in them.

My current code is copying all files and folders.

// config.xml<Config><Test><SourceDBBackupPath>\\server\D$\BACKUP</SourceDBBackupPath><DestinationRestorePath>\\server1\e$\BACKUP\;\\server2\e$\BACKUP\</DestinationRestorePath><DestinationServer>server1;server2</DestinationServer></Test></Config>

function CopyBackup($Region)
{
    if($Region -ieq "Test" )
    {
       $XPath = "Config/Test"
       $Xvalues =   Select-Xml -Path $configFile -XPath $Xpath | Select-Object -ExpandProperty Node

       $DestinationServers = $Xvalues.DestinationServer -Split ";"
       $SourcePath = $Xvalues.SourceDBBackupPath
       $DestinationPaths = $Xvalues.DestinationRestorePath -Split ";"      

       foreach ($DestinationPath in $DestinationPaths){
           Copy-Item $SourcePath -Destination $DestinationPath  -Recurse -force
       }     
       Write-Host "Files copied" 
      }
    }

Thanks

powershell. "Does a folder exist" command? (outlook not exchange)

$
0
0

I'm copying files from various folders in the mailbox to another folder in the same mailbox. (I am an end user, not an exchange admin).

however I need to check if the folder structure I am copying the mailitem  to exists (if not create it).

Done so much so far, but this one simply thing is annoying me (I have a workaround based on "if error, then create the folder structure"

Actually while you are here .... is there any mechanism to recursively create folders? eg \testA\testB\TestC in one go, rather than testa then testb  then test c?


Viewing all 21975 articles
Browse latest View live


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