首页 > 系统相关 >Power Shell

Power Shell

时间:2022-08-31 11:37:02浏览次数:39  
标签:files Shell Power filename item file New Path

Code:

$Path = "C:\Users\xxxx\Downloads\New";
$filename="$Path\c.txt";

#create file if it does not exist
if(-not (Test-Path $filename))
{
    New-Item -ItemType file -Path $filename
}

#write current date to file
$currentDate  = get-date
Add-Content $filename -Value $currentDate

#get files in the folder and assign items to a collection
$files = Get-ChildItem -Path $Path

#iterate item
foreach($item in $files){
    Write-Host $item
}

Result:
Result

标签:files,Shell,Power,filename,item,file,New,Path
From: https://www.cnblogs.com/luhe/p/16642363.html

相关文章

  • ARM Power Management总结
    Background许多ARM系统都是由电池供电的移动设备,对续航和散热有很高要求。如果不是电池供电,其实也同样对节能和散热等环境有一定要求。因此低功耗对ARM系统来说是非常重要......
  • 反弹shell
    参考文章:https://cloud.tencent.com/developer/article/1818091一些概念原理:反弹shell,就是攻击机监听在某个TCP/UDP端口为服务端,目标机主动发起请求到攻击机监听的端口,......
  • linux shell 中"2>&1"含义
    问题:在编译安卓操作系统的代码时候,一连需要10几个小时,为记录编译过程中间可能出问题,便于调试。需要把编译过程输出到文件。这样也可以设置自动关机了。  解决方案:编......
  • CCPC Qinhuangdao 2020 K, Kingdom's Power做题思路
    首先,对于一个子树,我们显然只有两种去让军队走过他的办法,一种是从兄弟节点调一些军队来,另一种是从根节点推过来。感觉有一个结论,就是我这个位置如果用兄弟节点推过来的只是......
  • shell编程【一】
    参考网址:【Linux命令大全】[]:https://linux265.com/course/linux-commands.html为什么要学习shell指令?学习shell指令的本身也是在了解Linux系统。shell是开发出来更好地......
  • Power Shell 生成ssh key
    生成新的SSH公私钥对以下PowerShell脚本检查是否存在已有的SSH公私钥对,如果不存在,则生成一对新的公私钥对if((-not(Test-Path-Path$HOME/.ssh-PathTypeConta......
  • gcp平台gcloud shell安装和使用
    参考文档:https://cloud.google.com/sdk/docs/install?hl=zh-cn在服务器上授权gcloud命令1、在iam处添加服务账号  2、授权editor的权限  3、添加密钥  4......
  • jenkins使用shell脚本执行nohup java -jar包失败
    一、问题通过jenkins执行shell脚本时,脚本中是通过nohupjava-jar&的方式启动,显示执行成功,但是服务却没启动,脚本如下:#!/bin/bashnohupjava-Xms800m-Xmx800m-XX:P......
  • 暑假学习6 hdfs shell命令
    命令行操作:cliHadoop的命令shell:Hadoopfs-lsfile:          操作本地的文件系统hadoopfs-lshdfs://node1:8020         ......
  • shell-流程控制
    流程控制执行脚本case语法case实例......