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

Recursively changing permissions on folders with long path names

$
0
0

I've gotten a request to change permissions on specific folders for every branch office my organization has - 260+. I'm ok getting the folders, but I'm not sure the output/variable will be ok to pass it into the next command.

$folders = gci -Recurse -path q:\ -include *"Long Foldername Search"* | select name

Will the output from that be suitable to pass to a command to change permissions assuming I can work with foldernames over 248 characters? I'm thinking I'll need a foreach statement, but I've never changed folder permissions in PowerShell before.


zarberg@gmail.com


Send-MailMessage the server response was: #4.x.2 Too many messages for this session

$
0
0

I have a scheduled task that will check for passwords expiring in 15 days or less and fire off a reminder email to the user that they have x days left to change it.  However, there are usually 70+ addresses in this list and after 10 messages are sent the following error appears:

The server response was: #4.x.2 Too many messages for this session

The script will continue and then after 10 more, the same error.  I have even moved the function using send-mailmessage to a separate .ps1 file and call it from the parent .ps1 but the error continues.  I don't want to bump up the concurrent connection limit on my relay, is there any clean way to close the send-mailmessage session?  Otherwise I'll probably just loop the task to catch the error condition.  For what it's worth, the server running this task has .NET 4.0 installed.

what does "%" mean in powershell syntax

$
0
0
I know that typically the "%" character is for mod functionality.  In some powershell scripts I've come across, I've noticed % being used after the | character and I can't seem to find what the syntax means.

For example. "$old | % { Remove-Item $_.SPBackupDirectory -Recurse }"   I can't figure out what | % is doing.....  is it a shorthand foreach expression?

Tony Testa www.tonytestasworld.com

Shutdown warning popup window in Windows 7

$
0
0
Hi all.

I need to execute a command that hibernates a set of computers remotely, and i get to the point that i have a psexec running a psshutdown to a list of computers from a file.
Untill now, all is OK.
In Windows XP it runs smoothlly, and shows a popup windows with a countdown with the time i set up in the command, and user can cancel it still need the machine or so.
I Windows 7, the command is executed, the countdown runs, but no popup warning windows is shown, so the user don't have a clue of what's going on, until the moment that the computer starts to hibernate.
Is there a way to make the popup window appear in the windows 7?
All the computers are running Windows 7 64bit with SP1 and belongs to an Active Directory Domain with a Windows Server 2003 DC.

Thanks a lot in advance.

BM

Count number of users in distribution group

$
0
0

Hi,

I need to find all distribution groups that have more than 50 recipient. I tried with this in ems:

$grupe = Get-DistributionGroup
$grupe | Where-Object { (Get-DistributionGroupMember -Identity $_.Name).Count -gt 50 }

And it is working, but if I have group in group it only count 1 and not member in child group. Example:

Group01@test.com

For group01 number is 4, but i need total number of recipinet.


Start-WebAppPool Remotely -Name Variable is sent as $Null

$
0
0

When I do this:

$Server = Read-Host "Enter Web Server Name"
$AppPool = Read-Host "Enter Application Pool to Restart"
Invoke-command -ComputerName $Server -ScriptBlock { Stop-WebAppPool -Name $AppPool }

I get this:

Cannot validate argument on parameter 'Name'. The argument is null. Supply a non-null argument and try the command again.

I'm guessing it has to with something like variable scoping.. I've seen a few examples of how to do this but the level of scripting in their examples is beyond me. 

This works for instance:

Invoke-command -ComputerName myComputerName -ScriptBlock { Stop-WebAppPool -Name RemoteTransfer }

but when I Read-Host and put in the extra {} in the ScriptBlock, my variable goes bye bye. 

Thanks in advance.

web test result for a URL which needs a client certificate to authenticate

$
0
0
Hi,

we want to check URL response of a .asmx URL which needs a client certificate for authenticating.
I got the cert object and then passed it to invoke-webrequest cmdlet, but no matter what i try I always get this error
“The underlying connection was closed”.

code1

$WebClient = New-Object System.Net.WebClient
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$WebClient.DownloadString(“https://server1/mywebservices/myser.asmx”)

code2
$url=”https://server1/mywebservices/myser.asmx”

$cert=(Get-ChildItem cert: -Recurse | where {$_.Thumbprint -eq “abcdefgh3333…..something”}| Select -First 1)

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
#load my client certificate defined by thumbprint

$HTTP_Request = [System.Net.WebRequest]::Create($url)
$HTTP_Request.ClientCertificates.Add($cert )
# We then get a response from the site.
$HTTP_Response = $HTTP_Request.GetResponse()

Can someone please help me.
Thanks


Manish

Issue with Pasting to Command Line/PowerShell

$
0
0

Hi,

We are unable to paste text from an application other than Command Prompt (CP) or Windows PowerShell (PS) to CP or PS.

  • The issue is only occurring on one of several Windows Server 2008 VMs.
  • The server has been fully patched and restarted since the issue first started to occur.
  • Copying and pasting text inside CP/PS and between other CP/PS windows works.
  • Copying and pasting text from CP/PS to other applications works.
  • UAC has never been turned on.
  • We attempted to troubleshoot via different Administrative and non-Administrative users.
  • We tried a clean boot - antivirus is not causing the issue.

Obviously performing a system recovery is an option.  We can copy and paste text to PS ISE from applications, which is an acceptable solution for PS users.  However, it is still unacceptable for CP users.

Thanks,

NuxCase




Error calling function;

$
0
0

Hi I have a requirement to connect to sql server and do various operations currently doing it through start-job but we find it very inefficient. Someone pointed to Runspace and this link.
http://powertoe.wordpress.com/2012/05/03/foreach-parallel/

But in my script i have something like this.

                

It works fine if i pass only one variable to function ForEach-Parallel like this.

$SQLServers= Get-Content "L:\cfg\tst2.cfg"
$SQLServers |ForEach-Parallel -MaxThreads 100{  

# Start MAIN #
...declarations..
then

try {
    $var=$_  

    connect to sql server --Then do some processing

   }

  catch
  {
$Error[0]
  }
  }#End 

  But If i have something like this it throws an error saying cannot index into a null array , any way to fix it ? I might have to pass multiple parameters.

  $SQLServers= Get-Content "L:\cfg\tst2.cfg"
  $Database ="DBADB"
  $email = "dba@testemail.com"
  $Parms =@()
  $Parms = @($SQLServers,$Database,$email)
$Parms |ForEach-Parallel -MaxThreads 100{  

# Start MAIN #
...declarations..


try {
    $var1=$parms[0]
$var2=$parms[1]
$var3=$parms[2]
---Then do some processing
   }

  catch
  {
$Error[0]
  }
  }#End 
  I need to pass various inputs to my script then call the ForEach-Parallel function, any way around this?

Thanks

Open an Excel spreadsheet with powershell getting error

$
0
0

I am trying to open an excel file within power shell. Here is the code i am using 

$excel

=New-Object-com excel.application

 

 

$excel

.Visible=$True

 

 

 

$excelfile

="C:\Users\adm_kmccallion\Desktop\AssetInventory.xlsx"

 

 

$sheet

='Test'

 

 

$ou

="ctnet.com/Eton"

 

 

 

#$ExcelWorkbook = $Excel.Workbooks.Open($ExcelFile, 2, $True)

$ExcelWorkbook

=$Excel.workbooks.open("C:\Users\adm_kmccallion\Desktop\AssetInventory.xlsx")

 

$ExcelWorkSheet

=$Excel.Worksheets.Item($Sheet)

 

but i am getting the following error

 

Method invocation failed because [System.__ComObject] doesn't contain a method named 'open'.

At C:\Users\adm_kmccallion\Desktop\test.ps1:11 char:39

+ $ExcelWorkbook = $Excel.workbooks.open <<<< ("C:\Users\adm_kmccallion\Desktop\AssetInventory.xlsx")

+ CategoryInfo : InvalidOperation: (open:String) [], RuntimeException

+ FullyQualifiedErrorId : MethodNotFound

 

Any idea why?



ParameterBindingException when pipelining an Outlook.Folder object to custom cmdlet

$
0
0

Hello all-

I've written a simple C# powershell cmdlet (Get-Store) that returns an Outlook Object Model Store object. Another cmdlet I've written reads the above Store object from the pipeline and creates an email folder (Get-Folder)

I get a ParameterBindingException when piping the returned store object from Get-Store to Get-Folder.

If I create the store object manually on the PS command line, via new-object, then pipe it to Get-Folder, it works.

It appears the errant store object is a __comObject type, while the store object that works is a Outlook.StoreClass type. Does anyone know how I can make this work?

Here's a transcript of the PS session:

---------------------------------------------------------------

PS c:\ps\mapi\bin\x64\Debug> import-module .\mapi.dll

PS C:\ps\mapi\bin\x64\Debug> $app = new-object -com Outlook.Application

PS C:\ps\mapi\bin\x64\Debug> $stores = $app.Session.stores

PS C:\ps\mapi\bin\x64\Debug> $storeOK = $stores[1]

PS C:\ps\mapi\bin\x64\Debug> $storeOK.GetType()

 

IsPublic IsSerial Name                                     BaseType

-------- -------- ----                                     --------

True     False    StoreClass                               System.__ComObject

 

 

PS C:\ps\mapi\bin\x64\Debug> $storeOK | Get-Folder -path inbox\works -CreateIfNotExist

 

 

Application            : Microsoft.Office.Interop.Outlook.ApplicationClass

Class                  : 2

Session                : Microsoft.Office.Interop.Outlook.NameSpaceClass

Parent                 : System.__ComObject

DefaultItemType        : 0

DefaultMessageClass    : IPM.Note

Description            :

EntryID                : 0000000029542A42175B114D983D2C3446907A490100B870629719727B4BA82A6C06A31C2912004C5FB6DB8F0000

Folders                : System.__ComObject

Items                  : System.__ComObject

Name                   : works

StoreID                : 0000000038A1BB1005E5101AA1BB08002B2A56C20000454D534D44422E444C4C00000000000000001B55FA20AA6611

                         CD9BC800AA002FC45A0C00000048514D41494C5356523031002F6F3D4964656E746943727970742F6F753D45786368

                         616E67652041646D696E6973747261746976652047726F7570202846594449424F484632335350444C54292F636E3D

                         526563697069656E74732F636E3D6C657300

UnReadItemCount        : 0

UserPermissions        : System.__ComObject

WebViewOn              : False

WebViewURL             :

WebViewAllowNavigation : True

AddressBookName        :

ShowAsOutlookAB        : False

FolderPath             :\\les@voltage.com\Inbox\works

InAppFolderSyncObject  : False

CurrentView            : System.__ComObject

CustomViewsOnly        : False

Views                  : System.__ComObject

MAPIOBJECT             : System.__ComObject

FullFolderPath         :\\les@voltage.com\Inbox\works

IsSharePointFolder     : False

ShowItemCount          : 1

Store                  : System.__ComObject

PropertyAccessor       : System.__ComObject

UserDefinedProperties  : System.__ComObject

 

 

 

PS C:\ps\mapi\bin\x64\Debug> $storeNotOK = Get-Store -StoreNameles@voltage.com

PS C:\ps\mapi\bin\x64\Debug> $storeNotOK.GetType()

 

IsPublic IsSerial Name                                     BaseType

-------- -------- ----                                     --------

True     False    __ComObject                              System.MarshalByRefObject

 

 

PS C:\ps\mapi\bin\x64\Debug> $storeNotOK | Get-Folder -path inbox\DoesntWork -CreateIfNotExist

Get-Folder : The input object cannot be bound to any parameters for the command either because the command does not

take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

At line:1 char:15

+ $storeNotOK | Get-Folder -path inbox\DoesntWork -CreateIfNotExist

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

    + CategoryInfo          : InvalidArgument: (System.__ComObject:PSObject) [Get-Folder], ParameterBindingException

    + FullyQualifiedErrorId : InputObjectNotBound,mapi.Get_OutlookFolder

Here's the code:

-------------------------------------------------------

namespace mapi

{

    [Cmdlet(VerbsCommon.Get,"Store")]

   publicclass Get_Store : PSCmdlet

    {

       protectedoverridevoid ProcessRecord()

        {

           base.ProcessRecord();

           this.WriteObject(_getStore());

           this.WriteDebug("Get-App::ProcessRecord");

        }

       publicApplication _getApplication()

        {

           Application app = newApplication();

           return app;

        }

 

        [Parameter(Position = 0, ValueFromPipeline =false)]

        [ValidateNotNullOrEmpty]

       publicstring StoreName

        {

           get { return _storeName; }

           set { _storeName = value.ToLower(); }

        }

       string _storeName;

 

       publicStore _getStore()

        {

           Application app = null;

           

            try

            {

               if (null == _storeName)

                   thrownew ArgumentException("Missing argument 'StoreName'");

 

                app = _getApplication();

 

               foreach (Store storein app.Session.Stores)

                {

                   if (store.DisplayName.ToLower() == _storeName)

                       return store;

 

                   if (null != store)

                       Marshal.ReleaseComObject(store);

                }

               returnnull;

            }

           finally

            {

              if (null != app)

                   Marshal.ReleaseComObject(app);

            }

        }

    }

    [Cmdlet(VerbsCommon.Get,"Folder")]

   publicclass Get_OutlookFolder : PSCmdlet

    {

        [Parameter(Position = 0, ValueFromPipeline =true, ValueFromPipelineByPropertyName = false)]

        [ValidateNotNullOrEmpty]

       public Microsoft.Office.Interop.Outlook.Store Store

        {

           get

            {

                return _store;

            }

           set

            {

                _store =value;

            }

        }

       Store _store;

 

       

        [Parameter(Position = 0,ValueFromPipeline =false)]

       publicstring Path

        {

           get { return _folderPath; }

           set { _folderPath = value; }

        }

       string _folderPath;

 

        [Parameter(Position = 1, ValueFromPipeline =false)]

       publicSwitchParameter CreateIfNotExist

        {

           get { return _createIfNotExist; }

           set { _createIfNotExist = value; }

        }

       bool _createIfNotExist=false;

       

        protectedoverridevoid ProcessRecord()

        {

           this.WriteDebug("Get-Folder::ProcessRecord");

           this.WriteObject(_createFolder());

        }

 

       privatevoid _createOrOpenFolder(string path,MAPIFolder parent, refMAPIFolder ret)

        {

           if (null == path ||"" == path)

            {

                ret = parent;

               return;

            }

 

           string [] toks = path.Split('\\');

 

           if (null == toks)

               thrownew ArgumentException("folder path is invalid: "+ _folderPath);

 

           string folderName = toks[0];

 

           MAPIFolder targetFolder = SearchChildFolders(parent, folderName);

           if (null != targetFolder)

            {

                path = path.Remove(0, folderName.Length);

                path = path.TrimStart('\\');

                _createOrOpenFolder(path, targetFolder,ref ret);

            }

           else

            {

               // start creating

               if (_createIfNotExist)

                {

                   foreach (string newFolderNamein toks)

                    {

                       //if (null != targetFolder)

                          // Marshal.ReleaseComObject(targetFolder);

 

                        targetFolder = parent.Folders.Add(newFolderName);

                       //Marshal.ReleaseComObject(parent);

                        parent = targetFolder;

                    }

                   // return the last one on the path

                    ret = targetFolder;

                }

               else

                   thrownew ItemNotFoundException("Folder '"+ folderName +"' not on the path '"+ _folderPath +"' and CreateIfNotExist argument not passed.");

            }

        }

       MAPIFolder SearchChildFolders(MAPIFolder parent,string name)

        {

           foreach (MAPIFolder fin parent.Folders)

               if (f.Name.ToLower() == name)

                   return f;

               else

                   Marshal.ReleaseComObject(f);

 

           returnnull;

        }

       // return the requested folder.

 

       publicMAPIFolder _createFolder()

        {

           if (null == _folderPath)

               thrownew ArgumentNullException("_folderPath");

 

           if (null == _store)

               thrownew ArgumentNullException("_store");

 

           MAPIFolder ret = null;

            _createOrOpenFolder(_folderPath,

                                _store.GetRootFolder(),

                                ref ret);

 

           return ret;

        }

    }

}


Remove-Item & Program Files folder: permissions error

$
0
0

I am attempting to use Remove-Item to delete a file in Program Files and getting a permissions error. But, I am a local admin, and I tried running the script as administrator. I have also tried -Force, to no avail. I hope I don't have to go back to the DOS kludge I used in VBScript.

Any thoughts?
Gordon

Solved - How to take ownership and change permissions for blocked files and folders in Powershell

$
0
0

Hello,
I was trying to take ownership & fix permissions on Home Folder/My Documents structures, I ran into the common problem in PowerShell where Set-Acl & Get-Acl return access denied errors. The error occurs because the Administrators have been removed from file permissions and do not have ownership of the files,folders/directories. (Assuming all other permissions like SeTakeOwnershipPrivilege have been enabled.

I was not able to find any information about someone successfully using native PS to resolve the issue.  As I was able to solve the issues surrounding Get-Acl & Set-Acl, I wanted to share the result for those still looking for an answer.
----
Question: How do you use only Powershell take ownership and reset permissions for files or folders you do not have permissions or ownership of?
----

Problem: 
Using the default function calls to the object fail for a folder that the administrative account does not have permissions or file ownership. You get the following error for Get-Acl:

PS C:\> Get-Acl -path F:\testpath\locked
Get-Acl : Attempted to perform an unauthorized operation.+ get-acl <<<<  -path F:\testpath\locked+ CategoryInfo          : NotSpecified: (:) [Get-Acl], UnauthorizedAccessException+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetAclCommand

If you create a new ACL and attempt to apply it using Set-Acl, you get:

PS C:\> Set-Acl -path F:\testpath\locked -AclObject $DirAcl
Set-Acl : Attempted to perform an unauthorized operation.
At line:1 char:8+ Set-Acl <<<<  -path "F:\testpath\locked" -AclObject $DirAcl+ CategoryInfo          : PermissionDenied: (F:\testpath\locked:String) [Set-Acl], UnauthorizedAccessException+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetAclCommand

Use of other functions like .GetAccessControl will result in a similar error: "Attempted to perform an unauthorized operation."

How do you replace owner on all subcontainers and objects in Powershell with resorting to external applications like takeown, icacls, Windows Explorer GUI, etc.?

Tony

Set-ADUser to modify givenname and surname attributes based upon displayname in powershell

$
0
0
Hello to everyone,

i'm trying to restore AD Users records to a proper shape.

More in details,current AD users records contains only the displayname and the other mandatory attributes,everything is lacking (like givenname,surname,telephonenumber,address,city,country ecc. ecc.)

Actuallly,i'm trying to achieve three results:

1 - Populate at least the Givenname and Surname from the displayname attribute (since this one is "name-space-surname")

2 - Populate the address,country,city based on the OU's membership

3 - populate the phonenumber attribute from a csv that i'm trying to build from mixing various others excel files

I need help for the first one.

An example of a displayname that i have is like:

"test1 Test2"

What i'm trying to do is to extract "test1"and assign as "Givenname" and extract "test2" and assign it as "surname"

How can i use Set-aduser to achieve what i want?

Thanks for any reply


Output to a CSV has incorrect format

$
0
0

Hello There,

I was attempting to output information to a csv via powershell, but each time I tried the format is incorrect. Below is the cmdlet I used to output to a csv file.

[PS] C:\Windows\system32>Get-PublicFolder -Recurse | Get-PublicFolderClientPermission | Select-Object Identity,User -ExpandProperty AccessRights > C:\Temp1\New_PFPerms.csv

I have included a screen shot of the outcome, and as you can see it is not very user-friendly. See below..

Any suggestion is greatly appreciated.

Regards,

HansAndFranz


Remove entire O365 tenant - completely start new

$
0
0

Due to multiple changes to our O365 tenant through custom PS CMDlet scripts we have written we are now in a state of non-usable tenant. This is/was our POC to pre-stage our environment for our O365 migration for our company.

So what I am looking to do is to remove the entire tenant and start fresh. I am specifically looking for CMDlets that will do this with the safest (Microsoft approved) approach. I know that I can remove users through PS, remove licenses through PS, ETC., but what I would like to ideally accomplish is a complete removal of the ENTIRE tenant so I can start fresh and build the new tenant properly.

Thank you in advance!

Automate a login script and exit Website - Problem with login in function

$
0
0

Hello All, 

I've started working on a script to login to a site automatically and have an output log file. 

The problem i have is the button (login nutton) line of code in my script, i'm not sure if it working or not and need some help and also would like the log file to include the URL and Success or Fail next to the URL. 

eventually then i would like to get -content from a txt file and have all the sites in the list with the same login  

(The inspect elemment feature on the login page (chrome) shows these details for the login button) 

function loginIE
{
$ie = New-Object -com "InternetExplorer.Application"
$ie.Navigate("http://URL.com")
$ie.visible = $true

do { sleep 5 }
while ( $ie.busy )

$doc = $ie.document
$user = $doc.getElementById("Login")
$password = $doc.getElementById("Password")
$submit = $doc.getElementById("Submit")

$user.value = "USER1"
$password.value = "USER2"
$submit.Click();

$ie.Quit();

$ie.Document.body | Out-File -FilePath c:\weblogin.txt
}




Trying to make a group local admin, but access denied. Which right to set correctly

$
0
0

Hi Guys,

I want to add an Active directory group as local admin. I use the following code:

$groupAdmin="Administrators"

$groupRdp="Remote Desktop Users"

$pathAdmin = [ADSI]"WinNT://$hostName/$groupAdmin,group"

$pathAdmin.psbase.Invoke("Add",([ADSI]"WinNT://$Domain/$LocalAdmin").path)

The code works when i try to do this. But when my Vcenter service user does this it gives an acces dienied error.

Where do i have to set rights? At computer (server) level or at group level, get this error:

Exception calling "Invoke" with "2" argument(s): "Access is denied.
"
At D:\scripts\addcomputerad-vco3.ps1:110 char:2
+     $pathAdmin.psbase.Invoke("Add",([ADSI]"WinNT://$Domain/$LocalAdmin").path
)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodTargetInvocation
 

Please don't come with domain admin rights, i need the best security practice.

Kind regards,

André

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Run Powershell script as Scheduled task, that uses Excel COM object

$
0
0

What am I missing here..

 

I have  Powershell script that uses the Quest AD cmdlets to get computer information from AD and populate an Excel spreadsheet with the data.

The script works fine, so I created a batch file and started the script from there (which works fine as well). It populates the excel spreadsheet, saves and closes the file.

If I run the script as a scheduled task, I can see from the logging that it supposedly gets the computers from AD, and runs through them. But a file is never saved, I have tried to run the scheduled task with admin credentials.

What am I forgetting?

Parsing sub-directories into csv

$
0
0

I have a directory with thousands of files all in an ordered sub-directory structure. I’m trying to export those files, along with their respective file paths, delimited, into a csv. Hierarchical order should be static in the csv: in the below example, ‘file.jpg’ should always appear in the fifth column of the csv, with any preceding missing values returning as null.

c:\master\sub1\sub2\sub3\sub4\file.jpg > in csv becomes > sub1, sub2, sub3, sub4, file.jpg

c:\master\sub1\sub2\sub3\file.jpg > in csv becomes > sub1, sub2, sub3, - , file.jpg

c:\master\sub1\sub2\file.jpg > in csv becomes > sub1, sub2, - , - , file.jpg

 

Before I had Powershell, I did something similar to this in the cmd prompt using this:

 

(for /r %f in (*) do @echo “%~dpf”, “%~nxf”, %~zf) >filename.csv

 

This exported the entire file path as a string, but without 1) delimiting the sub-directories, or 2) holding their positions static in the csv. So how do I include these two elements in the script?

 

I’ve found some Powershell commands that would also get close, but again, can’t figure out in Powershell how to perform actions 1 and 2.

 

Thanks.


Viewing all 21975 articles
Browse latest View live


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