Wildcard in URL - wildcard

I download a file from a sharepoint and the script works fine, but I need to specify the file that I want to download. this one have an increment number at this end. I don't want to specify this one (as it not always the same) in my script.
I would like to replace this one by a wildcard like * but without success till now. I'm a beginner in powershell :-(.
I hope that you can help me.
The code used is:
$Username="Username"
$Password="pwd"
$FileURL="http://Sharepoint/folder1/folder2/filenameWEEK08.xlsx".
$saveName ="C:\folder1\folder\filename.xlsx
$WebClient = new-object System.Net.WebClient
$WebClient.UseDefaultCredentials = $true;
$WebClient.Credentials = New-Object System.Net.Networkcredential($Username, $Password)
$WebClient.DownloadFile($FileURL, $saveName);
in this one I would like to replace WEEK08 by a * (or something like this)
Than you in advance for your help.
patrick

Related

How to get rid of the original file path instead of name in PGP encryption with ChoPGP library?

I tried PGP encrypting a file in ChoPGP library. At the end of the process it shows embedded file name along with the whole original file name path.
But I thought it will show only the filename without the whole path. Which I intend to work on and figure out a way to do so?
Doing the following:
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
pgp.EncryptFile(#"\\appdevtest\c$\appstest\Transporter\test\Test.txt",
#"\\appdevtest\c$\appstest\Transporter\test\OSCTestFile_ChoPGP.gpg",
#"\\appdevtest\c$\appstest\Transporter\pgpKey\PublicKey\atorres\atorres_publicKey.asc",
true,
true);
}
which will result in:
But I would like to only extract the Test.txt in the end something
like this:
Looking at this line from the ChoPGP sources: https://github.com/Cinchoo/ChoPGP/blob/7152c7385022823013324408e84cb7e25d33c3e7/ChoPGP/ChoPGPEncryptDecrypt.cs#L221
You may find out that it uses internal function GetFileName, which ends up with this for the FileStream: return ((FileStream)stream).Name;.
And this one, according to documentation, Gets the absolute path of the file opened in the FileStream..
So you should either make fork of ChoPGP and modify this line to extract just filename, or submit a pull request to the ChoPGP. Btw, it's just a wrapper around the BouncyCastle so you may use that instead.

Find Excel connections paths using PowerShell/R/VBA

I need to list all the connection paths from multiple Excel files. So far, I have been able to get the connections names, but I require the full path. I have used the following PowerShell code, posted by a fellow user here.
ForEach ($file in(Get-ChildItem "\path\to\file" -recurse))
{
$Excel = New-Object -comobject Excel.Application
$ExcelWorkbook = $Excel.workbooks.open($file.fullname)
write-host "Connections of $($file.fullname):"
$ExcelWorkbook.Connections
$ExcelWorkbook.Close()
}
I also have R and VBA in hand to make this happen, but I could not think of any way to do this in any of them.
Thank you!

Using Jsch ChannelSftp put to a GDG file on mainframe

I'm currently stuck on trying to find a way to put to a generation data group (GDG) on mainframe(zos) using Jsch.
The command line syntax would be
put myFile.txt GDG.MYGDG(+1)
This I know works fine when using sftp or ftp command via a linux shell. I have not found any way to replicate this via the put method of the ChannelSftp class.
I have searched wide and far looking for examples and not found any which makes me think it is not possible with this framework.
Any help would be appreciated.
UPDATE
adding some example code. This is not the full code but shows what I have tried.
String localFileName = localFile.getName();
String remoteFile = "GDG.GDGROUP1(+1)";
FileInputStream inputStream = new FileInputStream(localFile);
ChannelSftp channelSftp = this.getChannelSftp();
String pwd = channelSftp.pwd();
channelSftp.put(inputStream, remoteFile);
The put call always returns that this is directory. I have also tried this for the remote file:
String remoteFile = localFile + " GDG.GDGROUP1(+1)";
This just returns failure.
I have tried absolute path using // and /-/. So far nothing has worked.

Powershell command for IIS 7 for replacing one string with another

I have a configuration setting in web. config file as follows:
<param name="url" value="http://localhost/services.msc">
I want to write a batch file using powershell to replace value="http://localhost/services.msc"
with port number as value="http://localhost:808/services.msc"
Is it possible to replace one text with another?
There are several ways to do this. My favorite way to modify any XML file if I know the value I'm trying to modify is to cast the content as XML, find the setting right where I know it to be, to modify it, and then to set the content of the config file to what I now have in powershell. An example is below. To find the exact value I usually take the item above it and pipe it to | fl until I get exactly what I'm looking at. You can read the XML and get the info probably alot easier.
#Make sure you set the webconfigpath variable.
#Make sure you know your keyname and where to find it in the XML doc.
$webConfig = [xml](Get-Content -path $webConfigPath)
$setting = $webConfig.configuration.appSettings.add | ?{$_.key -eq "KeyName"}
$setting.Value = "NewValue"
$webConfig.save($webConfigPath)
This may be something that can be changed with the Set-WebConfigurationProperty cmdlet, but I'm not sure and haven't used it personally.

BizTalk SourceFileName becomes dehydrated

I'm trying to use a custom filename since i need to create two files (a backupfile) so i followed the following tutorial to create filename Here
now when i test this with DELCUS%MessageID%.txt everything works fine but when i change it to DELCUS%SourceFileName%.txt the interface becomes permanently dehydrated.
the only thing i do for the filename is this
fileName = "ContExt" + System.DateTime.Now.ToString();
Message_send_Belspeed_BeautDay_ContExt(FILE.ReceivedFileName) =
fileName;
is there any reason why the use of SourceFileName would cause this to dehydrate?
Found the issue.
after a while the interface did crash and the filename looks like
DELCUS2012 10:50:40.txt
having : in a filename is not good.
This is just a standard windows file naming limitation, you can't name your file using any of these characters "\ / : * ? " < > |". So obviously your instances are going to get stuck!!

Resources