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

AppFabricCachingService DOWN on 1/4 Caching Host

$
0
0

Good Afternoon,

Running AppFabric farm with SQL on 4 2008 R2 servers. Unable to get 1/4 servers to come up when issuing Start-CacheCluster PS command.

Ports are open between these servers. I've tried full reboot on all servers, including SQL. I've rebuilt the problem server and reinstalled AppFabric with no resolution.

Thanks,

Joe


Query DNS secondary zone for Master servers

$
0
0

Is there a way via PowerShell to query a DNS secondary zone and return the list of Master Servers? I guess I'm essentially looking for a Get equivalent of Add-DnsServerSecondaryZone but that doesn't exist as far as I can see.

My aim is to create a script for deleting a secondary zone from each of our DNS servers (simply enough), but before I delete it I'd like to retrieve the master server details so I can spit them out into a logfile. That way should someone accidentally delete the wrong secondary we can see from the logs where it was previously pointing to and set it up again.

Powershell command to 'refresh' a virtual switch extension manager.

$
0
0

Hi. I'm working on integrating Cisco's Nexus 1000v (N1KV) virtual switch with Hyper-V.  After I configure the N1KV, I have to manually refresh the corresponding virtual switch extension manager on SCVMM, to display the logical network I configured on the N1KV.  Is there a corresponding powershell command to do this refresh?

Open network folder

$
0
0

I got the folder open when I ran Start '\\PCName\c$\Users'

But I got error when I ran

$a = 'PCName'

Start '\\' + $a + '\c$\Users'

The error is

Start-Process : A positional parameter cannot be found that accepts argument 'PCName'.
At line:1 char:1
+ Start '\\' + $a + '\c$\Users'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

Query failover cluster via powershell to obtain virtual machine operating system

$
0
0

Looking at the 'roles' in 2012 failover cluster manager shows a field 'operating system'

I'd like to query this via powershell - I'm thinking get-clusterresource is the way to go but I'm looking for feedback

Download multiple files simultanously using an access database as url source?

$
0
0

I have an access database with a bunch of url's that points to images. What i want to do is to create a script that goes through my database and downloads all of the images simultanously.

I have tried out this script from Scripting Guy where i can pull records from access database. This screates a list with all the url's in the database, but is there a way I can tweak the script to download the images? PS-scripting is new for me so i appreciate any help you can give me. I don't ask you to solve this for me, just to help me get started :)

$adOpenStatic = 3 $adLockOptimistic = 3 $objConnection = New-Object -comobject ADODB.Connection $objRecordset = New-Object -comobject ADODB.Recordset $objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\data\powershell\dbpowershell.mdb") $objRecordset.Open("Select * from TABLE", $objConnection,$adOpenStatic,$adLockOptimistic)

$url = $objRecordset.Fields.Item("url").Value
$path = "c:\test.jpg"

$webClient = new-object System.Net.WebClient; $objRecordset.MoveFirst() do {$objRecordset.Fields.Item("url").Value; $objRecordset.MoveNext()} until ($objRecordset.EOF -eq $True)

foreach ($urls in $url) {$webclient.downloadfile($url, $path)}

$objRecordset.Close() $objConnection.Close()

I am able to download "one" image when adding the following into my code:

$url = $objRecordset.Fields.Item("url").Value
$path = "c:\test.jpg"

foreach ($urls in $url) {$webclient.downloadfile($url, $path)}






Exporting Group Policy Settings into Excel - Help Needed!!!

$
0
0

All,

 I have installed Microsoft GPMC Sample Scripts and used the command "cscript GetReportsAllGPOs.wsf" to get all the lists of GPOs in our domain. As you all know, the above command exports all GPO files as HTML and XML version of each GPO in the domain. I've been able to export the xml files into excel to view the data.

The issue is that I did not see all the interesting data I needed. I need to retrieve information such as :

1. Domain

2. GPO Name

3. Policy Path e.g Computer Configuration\Policicies\Windows Settings\Account Policies\Password Policy

4. Policy Setting Name e.g Enforce Password History

5. Policy Links e.g to each OU, Domain, or Site

The sections I see in the Excel spreadsheet are # 1 and 2.

Can someone help with a script to retrieve the above information from the domain environment or from the xml and html files I've already retrieved from the "cscript GetReportsAllGPOs.wsf" command?

Thanks in advance,

TeeDarling77


Need help with PS Script to add Computers to Groups based on Computer Description

$
0
0

Hi all,

I'm looking for an alternative way to write my script to add any computer matching a filter, then adding a computer based on it's description, to a security group. All the computers that start with WS are being filtered. I'd like to grab the AD description field and then add that computer to a AD group based on its description. Heres what I have so far and it works, but the if statement nesting is nasty. Thanks for the help in advance!

Import-Module ActiveDirectory
Add-PSSnapin Quest.ActiveRoles.ADManagement -EA SilentlyContinue
$ErrorActionPreference="SilentlyContinue"
$workstations = Get-ADComputer -filter {(Name -like "WS*")} -Properties Description | Select-Object Name, Description | Sort-Object Name
foreach ($workstation in $workstations){
if ($workstation.Description -like "5ICU-RMC-5"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.5ICU.RMC"}
elseif ($workstation.Description -like "MHU-Adlt-RMC2"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.MHU.Adult.400Bldg"}
elseif ($workstation.Description -like "MHU-BSU-RMC2"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.MHU.BSU.400Bldg"}
elseif ($workstation.Description -like "MHU-GSU-RMC2"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.MHU.GSU.400Bldg"}
elseif ($workstation.Description -like "MHU-ChAdlt-RMC2"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.MHU.Child.400Bldg"}
elseif ($workstation.Description -like "MHU-Adlt-RMC2"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.MHU.Adult.400Bldg"}
elseif ($workstation.Description -like "Sound-400-302"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.SoundHospitalist.400Bldg"}
elseif ($workstation.Description -like "IS-RMC"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.IS.400Bldg"}
elseif ($workstation.Description -like "NSGAdm-400-305"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.NursingAdmin.400Bldg"}
elseif ($workstation.Description -like "BA-IS-400-407"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.BusinessAnalytics.400Bldg"}
elseif ($workstation.Description -like "RMG-NS-400-402"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.NeuroSurgery.400Bldg"}
elseif ($workstation.Description -like "RMG-PMR-400-400"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.PMR.400Bldg"}
elseif ($workstation.Description -like "EKG-400-500"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.EKG.ProcTesting.400Bldg"}
elseif ($workstation.Description -like "5Rehab-400-5"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.5Rehab.400Bldg"} 
elseif ($workstation.Description -like "IS-Info-401-StB"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.Informatics.401Bldg"}
elseif ($workstation.Description -like "MedRec-401-Bsmt"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.MedRec.401Bldg"}
elseif ($workstation.Description -like "WrdPrc-401-Bsmt"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.WordProc.401Bldg"}
elseif ($workstation.Description -like "Wound-401-Bsmt"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.WoundCtr.401Bldg"}
elseif ($workstation.Description -like "Ambulance-Atr"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.Ambulance.Atr"}
elseif ($workstation.Description -like "RehabOP-Atr"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RehabSvcsOP.Atr"}
elseif ($workstation.Description -like "RMG-CorpH-Atr"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.CorpHealth.Atr"}
elseif ($workstation.Description -like "RMG-Pul-500-100"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.PulmCare.500Bldg"}
elseif ($workstation.Description -like "RMG-PSY-500-200"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.Psych.500Bldg"}
elseif ($workstation.Description -like "RMG-Nro-500-300"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.Neurology.500Bldg"}
elseif ($workstation.Description -like "RMG-Pul-500-300"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.Rheumotology.500Bldg"}
elseif ($workstation.Description -like "RMG-Pul-500-100"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.PulmCare.500Bldg"}
elseif ($workstation.Description -like "AIC-RMC-500"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.AIC.500Bldg"}
elseif ($workstation.Description -like "Cardiac-500-400"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.CardiacRehab.500Bldg"}
elseif ($workstation.Description -like "RMG-Card-500"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.Cardio.500Bldg"}
elseif ($workstation.Description -like "RMG-CardV-500"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.RMG.CardioV.500Bldg"}
elseif ($workstation.Description -like "EKG-500-Bsmt"){Add-ADPrincipalGroupMembership -identity ($workstation.name + "$") -memberof "SG.EKG.500Bldg"}}



Powershell Scripting Question

$
0
0

Hello all,

I have a script that actually runs perfectly fine, but I did notice - after extensive testing - that when I add a wmic command inside my script to perform an uninstall, everything works as it's supposed to, but at the end of the script it, my error handling grabs this:

  + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Any ideas on how I can rectify this? I don't want any errors in my script, even if they're benign.

Thanks!

Some Storage CMDLets do not work under WinPE

$
0
0

I have built a custom WinPE based on W2012 and included Powershell and a number of the Powershell CMDLets such as SMB, DISM, and Storage. Everything works fine. When you boot the WinPE disk and do a get-command -module Storage, it shows all of the Storage CMDlets. I am trying to do some simple automation and wrote a very simple script to initialize, partiion and format a disk

Initialize-disk 1 -PartitionStyle MBR
New-Partition  -diskNumber 1 -DriveLetter L -UseMaximumSize | `
  Format-Volume -FileSystem NTFS -NewFileSystemLabel "Stuff"

When I run this script on a W2012 server it works fine. When I run it from by WinPE disk the Format does not work. No error messages. Nothing. The first 2 statments work but the disk never is formatted and no label is assigned. The same is true with the Clear-Disk Cmdlet. I execute it under W2012 and it works fine. When I execute it under Win-PE it just returns to me and does nothing. I even tried just executing the Format-Volume Cmdlet by itself on WinPE and got the same result -- it immediately came back with no error message and did nothing.

It seems like some cmdlets work and some don't. Anyone have any thoughts?

Thanks

Roger


Roger

add a progress bar for each file downloaded

$
0
0

Im downloading a bunch of files using the webclient downloadfileasync method. The url soruce is an access database. I got some really good help doing it in this thread.

The progress bar idea is stolen from here. That helped me alot and im managing to get a progress bar running, but for now i only got one progress bar. For every other file i get and error that says:"Register-ObjectEvent : Cannot subscribe to event. A subscriber with source identifier 'WebClient.DownloadProgressChanged' already exists." 

Here is the full script:

 $adOpenStatic = 3
$adLockOptimistic = 3

$objConnection = New-Object -comobject ADODB.Connection
$objRecordset = New-Object -comobject ADODB.Recordset

$objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = d:\powershell\test1.mdb")
$objRecordset.Open("Select * from TBL", $objConnection,$adOpenStatic,$adLockOptimistic)

$objRecordset.MoveFirst()



 while($objrecordset.EOF -ne $true){
 foreach($urls in "url")
 {
 $url = ($objRecordset.Fields.Item("url").Value)
 $filename = "d:\powershell\" + ($objRecordset.Fields.Item("navn").Value) + ".jpg"

 getfile $url $filename

 }
  $objRecordset.MoveNext()


 }

 #######################
   
  
 function getfile($url, $filename)  
  
  {
   $wc = New-Object System.Net.WebClient
   Register-ObjectEvent -InputObject $wc -EventName DownloadProgressChanged -SourceIdentifier WebClient.DownloadProgressChanged -Action { Write-Progress -Activity "Downloading: $($EventArgs.ProgressPercentage)% Completed" -Status $url -PercentComplete $EventArgs.ProgressPercentage; }    
   Register-ObjectEvent -InputObject $wc -EventName DownloadFileCompleted -SourceIdentifier WebClient.DownloadFileComplete -Action { Write-Host "Download Complete - $filename"; Unregister-Event -SourceIdentifier WebClient.DownloadProgressChanged; Unregister-Event -SourceIdentifier WebClient.DownloadFileComplete; }  
   try  
   {  
     $wc.DownloadFileAsync($url, $filename)  
   }  
   catch [System.Net.WebException]  
   {  
     Write-Host("Cannot download $url")  
   }   
  finally  
   {    
     $wc.Dispose()  
   }
    }
 $objRecordset.Close()
$objConnection.Close()

How to get Attachment details using powershell cmdlets

$
0
0

Is it possible to get attachment name,size etc of a mail item  in the mailbox
by using powershell cmdlets ???


Add newline after a specified line

$
0
0

Hi

 Good Day

How i can search in alot of files and add new line after a specified content ..

How can I add a blank line to a text file using PowerShell?

$
0
0

The TechNet article seems straightforward - use Add-Content <filename> and put `n at the end of your string to add an extra line. (http://technet.microsoft.com/en-us/library/ee156791.aspx)

I've tried appending the newline character to my output string 

     $string = "My Output Text`n"
     Add-Content c:\myfile.txt $string
this results in My Output Text`n appearing on a single line in my output file

I tried setting a variable to equal "`n"

  $blankLine = "`n"
  Add-Content c:\myfile.txt $blankLine
This results in the script halting and prompting:

   cmdlet Add-Content at command pipeline position 1
   Supply values for the following parameters:
   Value[0]:
 

I've tried just passing the newline character as a literal

  add-content c:\myfile.txt "`n"

 this results in the script halting and prompting:

   cmdlet Add-Content at command pipeline position 1
   Supply values for the following parameters:
   Value[0]:

I've also tried using "`r`n" using the methods above (instead of just "`n") with the same results. 

Now for the crazy part.  If I do everything from the PowerShell commandline, e.g., Add-Content c:\myfile.txt "`r`n`r`n`r`n", the cmdlet puts three blank lines in the output file, no questions asked.  BTW-if I used "`n`n`n" I got only one blank line in my output file.

All I want to do is write a blank line to the output file from my script, so maybe Add-Content is the wrong cmdlet.  What am I doing wrong?  This is driving me crazy!


Check Whether drive exists

$
0
0
function get-checkdrive($server)
{	
		write-verbose "check drive -started"
	    $check= 'D:\' # no escape 
		$testobj=get-wmiobject win32_volume -filter  "DriveLetter= 'D:'" -computername $server
		$caption= $testobj.Caption
		if($check -contains ($caption) )
		{ 
			$TotalGB=@{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/1073741824),2)}}
			$FreeGB=@{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace /1073741824),2)}}
			$test=$testobj|Select Name , $TotalGB,$FreeGB	
		    write-verbose "check drive -Completed"
            return ($test)
        }
        else                
        { 
			write-output "$check doesnt exist"
        }
}

I have wriitten this script to check whether the D DRIVE exist or not. the script works fine but the problem is if D doesn't exist it doesn;t print drive doesnt exist instead print

@{Name=D: , Freespace(GB)=0 , Capacity(GB)=0). please help.


Start-BitsTransfer Works when triggered manually from powershell but not using a windows service

$
0
0

I'm using BITS to transfer file from one windows 2008 R2 server to the other. When I run the command manually from powershell or regular command line it works perfectly. Now when I use the same command as part of a build script in Jenkins it fails with the following error :

Start-BitsTransfer : Cannot find path '\192.168.1.210\C$' because it does not exist.

Jenkins runs as a windows service under "Local System" account. I thought changing the windows service to run under "Network Service" account might help, but that's not the case either.

Is there's some security reason which does not allow BITS to run from a windows service?

Here's the Powershell script I have deploy.ps1:

FunctionGet-PSCredential($User,$Password){
 $SecPass = convertto-securestring -asplaintext -string $Password -force
 $Creds = new-object System.Management.Automation.PSCredential-argumentlist $User,$SecPassReturn $Creds}

$credential =Get-PSCredential-User jenkins -Password jenkinsImport-ModuleBitsTransferStart-BitsTransfer-source c:\file.zip -destination \\192.168.1.210\C$\Website -credential $credential

Confirming again, the above powershell script works perfectly fine when i trigger it manually myself using powershell or windows command.

This is the command I use in Jenkins to trigger the script:

Powershell.exe -noprofile -executionpolicy Bypass-file C:\deploy.ps1 

alternative way to map a drive letter to a shared folder

$
0
0

Unfortunately none of the above meets my case and it gets more puzzling as I go forward.  Our office does not have a Domain, just a plain Workgroup. We have two Servers, one 2008 R1 one 2008 R2.<o:p></o:p>

About a year ago, I had a ton of problems when we took the old 2008 R1 server off line and replaced it with a
new 2008R2 took over. Suddenly about half the people could not map network drives any more. They can connect their VPN with no problem but cannot map the shared folders.<o:p></o:p>

Moving forward, as we got more updates from MS (I Guess?) I don't really know but
slowly eventually, everyone got back in except for two or three. these I was
able to prove were caused by a block on port 445 by their ISP's. Apparently 2008
R1 did not need port 445 to map drives  Of the few that were left, two paid for a business upgrade
for the internet at their home and that solved the problem. no port 445 block on business service.<o:p></o:p>

The last one though, opted to use her cellphone (an HTC) which also apparently did not
block that port.<o:p></o:p>

In the meantime, I figured why waste a good (but Old) server and I put the 2008 R1 unit back online as a "backup" mirror
to the new server on R2. and sure enough the person on her cellphone was able to connect right away to the old R1 and did not need the cellphone to connect to  it any more. She just connected direct to the R1 server/mirror. Same folders, and
they were synced regularly so no problem. <o:p></o:p>

Until now.

After the MS update a week or so ago, she can no longer connect to anything.  Worse, during the "good times" she got a new cellphone and it also will not pass a drive mapping (test)   it can be used to connect to the internet, thered to her laptop.  She can even make the VPN connection.  But she cannot map a single drive.

I tend to believe this is once again a port 445 issue but whether it is or not, I have no
idea what to do about it. Last time we went so far as to set up a website and
even mapped her to it as a "network place".   But the software that uses the mapped
drives will not work on anything but a REAL mapped drive. I tried at least 10
different odd things none of which worked.<o:p></o:p>

If she could not connect the VPN, I might be a little less concerned but the VPN
clicks through like instantly. Worse, I just had her ship her laptop here for servicing
and I did a complete reload and it worked exactly as it should. Until she got
it back. Still works perfect except no drive mapping.<o:p></o:p>

I am just throwing this out there and hoping that someone else has already found a solution for
something like this.  I asked the same questions when this happened a year ago and no one had any ideas then but maybe things have changed

PS: Sorry for the typos. I tried to fix them and I think it got worse instead

Compressing Log Files from Multiple Sources?

$
0
0

I need some help with a problem I'm facing at work. I've been tasked with developing a script to take video files older than a day stored from multiple directories and placing them in zipped folders named after their parent directory.

For example, I would need to search for all files in C:\DirA and move them to C:\ Archive\DirA(date-1).zip I would then need the script to go to C:\DirB and move them to C:\ArchiveDirB(date-1).zip and so on. 

I'm really lost and I don't have much of an idea on how to tackle this one. I have a partial script from another discussion thread that is running into errors with the actual zip process. Any help would be greatly appreciated.

Here is the actual code I'm trying to use. This code lacks the needed parts for moving the individual parts from the subfolders and doesn't quite work...

#usage: creat new zip function
function New-Zip
{
	param([string]$zipfilename)
	set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
	(dir $zipfilename).IsReadOnly = $false
}

#usage: -Recurse | add-Zip
function Add-Zip
{
	param([string]$zipfilename)

	if(-not (test-path($zipfilename)))
	{
		set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
		(dir $zipfilename).IsReadOnly = $false	
	}
	$shellApplication = new-object -com shell.application
	$zipPackage = $shellApplication.NameSpace($zipfilename)
	foreach($file in $input) 
	{ 
            $zipPackage.CopyHere($file.FullName)
            Start-sleep -milliseconds 500
	}
}

#Change these variables to meet needed reqs

$targetFolder = 'D:\sample'
$destinationFolder = 'C:\sample'
$now = Get-Date
$days = 1
$lastWrite = $now.AddDays(-$days)

#usage: destination folder

Get-ChildItem $targetFolder -Recurse | Where-Object { $_ -is [System.IO.FileInfo] } | ForEach-Object {
	If ($_.LastWriteTime -lt $lastWrite)
	{
		$_ | New-Zip $($destinationFolder + $_.BaseName + $lastWrite + ".zip") 
		$_ | Add-Zip $($destinationFolder + $_.BaseName + $lastWrite + ".zip")
	}
}

Pass Complex types as parameter in Remote powershell execution

$
0
0

Hi

    I am trying to pass a parameter to a remote script with an invoke-command.

    If i run the invoke command with the script in the local computer it´s works, but when i call the invoke-command with the second script in other server it´s fails with a conversion error for the type [System.Collections.Specialized.NameValueCollection]

    I think this can be because some serialization to transfer the data between the two servers. Any help??

   The command:

 Invoke-Command -computername $RemoteServerName -Credential $credential -Authentication Credssp -scriptblock {
       param(
            [String]$scriptDeploy,
            [String]$BackupPath,    
            [String]$DeployPath,
            [System.Collections.Specialized.NameValueCollection]$dtsConfigReplacements,
            [System.Collections.Specialized.NameValueCollection]$dtsxReplacements
            )  &"$scriptDeploy"  -BackupPath $BackupPath -DeployPath $DeployPath  -dtsConfigReplacements $dtsConfigReplacements  -dtsxReplacements $dtsxReplacements
         } -ArgumentList $Script_To_Run,  $script:BackupPath, $script:DeployPath, $script:dtsConfigReplacements,  $script:dtsxReplacements

    The command fails with this error:

Cannot process argument transformation on parameter 'dtsConfigReplacements'. Ca
 nnot convert the "System.Collections.ArrayList" value of type "System.Collectio
 ns.ArrayList" to type "System.Collections.Specialized.NameValueCollection".
 + CategoryInfo          : InvalidData: (:) [BDesarrollo.
 ps1], ParameterBindin...mationException
 + FullyQualifiedErrorId : ParameterArgumentTransformationError,Deploy.Aprovisionamiento.Desarrollo.ps1
 


Compare-object then conpare date modified

$
0
0

Hi,

I am comparing 2 folders and copying the different files.  Unfortunately I have some files (after a specific date) that I don't want to copy.  Can I exclude these files using date modified property?  Here is what I have so far:

$source = 'e:\folder1'
$destination = 'e:\folder2'

#Compare the 2 folders
Compare-Object $Folder1 $Folder2 -Property Name | Where-Object {$_.SideIndicator -eq "<="} | ForEach-Object {

#Sudo code
If date modified less than 10 days

       Copy-Item "$source\$($_.name)" -Destination "$destination" -Force
#write-host $source\$($_.name) -foregroundcolor red
        }

Thanks

James


Alter De Ruine

Viewing all 21975 articles
Browse latest View live


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