If you need to test file system load, test failover clusters, or need large dummy files otherwise, rather than creating new files and slowly filling them with random data, try this:
$filepath = "$env:temp\testfile.txt"
$sizeBytes = 5.75MB
$file = [System.IO.File]::Create($filepath)
$file.SetLength($sizeBytes)
$file.Close()
$file.Dispose()
# show dummy file in Windows Explorer
explorer /select,$filepath
This code creates dummy files of any size in a snap and can be used to quickly create storage load. Just don’t forget to delete these files after use.
# replace URL with any web page you like: $url = 'www.tagesschau.de' (Invoke-WebRequest-Method Head -Uri$url-UseBasicParsing).RawContent
诀窍是使用 -Method 参数并提交 Head 值来获取消息头而不是网页内容。
结果类似于:
HTTP/1.1 200 OK
Connection: keep-alive
Access-Control-Allow-Origin: *
Cache-Control: max-age=14
Content-Type: text/html; charset=utf-8
Date: Tue, 10 Aug 2021 12:06:37 GMT
The header info returned by a web page can vary greatly. When you replace the URL in above example with ‘www.google.de’, for example, you see many more instructions being sent to your browser, and you can actually “see” how the web page instructs your browser to set new cookies – so you can check whether the web page sets cookies before asking for consent or not: 网页返回的标题信息可能会有很大差异。例如,当您将上面示例中的 URL 替换为 “www.google.de" 时,您会看到更多的指令被发送到您的浏览器,您实际上可以“看到”网页如何指示您的浏览器设置新的 cookie——因此您可以在征求同意之前检查网页是否设置了 cookie:
HTTP/1.1 200 OK
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Date: Tue, 10 Aug 2021 12:07:06 GMT
Expires: Tue, 10 Aug 2021 12:07:06 GMT
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Set-Cookie: NID=221=C8RdXG_2bB_MwOG33_lS0hx3P5TF5_vaamoT0xj3yKgZPzCjr_g70NvJXkhenV_GMt1TYYU6XwmNOtlkRKRADiXgYJWWYp671M3DFL8DCxM_J1Cl01r39-jfA7sIxu1C
-0B7CHI-8WfXj5IGZ5dHtRxndNA84cpQov5phLhi7l8; expires=Wed, 09-Feb-2022 12:07:06 GMT; path=/; domain=.google.de; HttpOnly
Server: gws